From 417d14f0b946dcbf17e8d0148a1338e079ee9a8b Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Mon, 24 Jul 2023 16:02:29 +0800 Subject: [PATCH] Move packages under runtime to admin-core and rebuild dependency --- .../eventmesh-admin-core/build.gradle | 23 +++- .../eventmesh/admin/core/Constants.java | 29 ---- .../core/controller/AdminController.java | 59 -------- .../controller/ClientManageController.java | 50 +++---- .../core}/controller/HttpHandlerManager.java | 2 +- .../core}/handler/AbstractHttpHandler.java | 4 +- .../core}/handler/ConfigurationHandler.java | 8 +- .../handler/DeleteWebHookConfigHandler.java | 4 +- .../admin/core}/handler/EventHandler.java | 8 +- .../core}/handler/GrpcClientHandler.java | 12 +- .../core}/handler/HTTPClientHandler.java | 12 +- .../handler/InsertWebHookConfigHandler.java | 4 +- .../admin/core}/handler/MetricsHandler.java | 8 +- .../QueryRecommendEventMeshHandler.java | 4 +- .../QueryWebHookConfigByIdHandler.java | 6 +- ...eryWebHookConfigByManufacturerHandler.java | 6 +- .../RedirectClientByIpPortHandler.java | 4 +- .../handler/RedirectClientByPathHandler.java | 4 +- .../RedirectClientBySubSystemHandler.java | 4 +- .../admin/core}/handler/RegistryHandler.java | 8 +- .../core}/handler/RejectAllClientHandler.java | 4 +- .../handler/RejectClientByIpPortHandler.java | 4 +- .../RejectClientBySubSystemHandler.java | 4 +- .../handler/ShowClientBySystemHandler.java | 4 +- .../core}/handler/ShowClientHandler.java | 4 +- .../ShowListenClientByTopicHandler.java | 4 +- .../admin/core}/handler/TCPClientHandler.java | 12 +- .../admin/core}/handler/TopicHandler.java | 12 +- .../admin/core/handler/TopicsHandler.java | 130 ------------------ .../handler/UpdateWebHookConfigHandler.java | 4 +- .../core}/request/CreateTopicRequest.java | 2 +- .../request/DeleteGrpcClientRequest.java | 2 +- .../request/DeleteHTTPClientRequest.java | 2 +- .../core}/request/DeleteTCPClientRequest.java | 2 +- .../core}/request/DeleteTopicRequest.java | 2 +- .../core/request/TopicCreateRequest.java | 67 --------- .../eventmesh/admin/core}/response/Error.java | 2 +- .../core}/response/GetClientResponse.java | 2 +- .../response/GetConfigurationResponse.java | 2 +- .../core}/response/GetMetricsResponse.java | 2 +- .../core}/response/GetRegistryResponse.java | 2 +- .../admin/core/response/TopicResponse.java | 72 ---------- .../admin/core/util/RequestMapping.java | 94 ------------- .../admin/core/util/UrlMappingPattern.java | 117 ---------------- .../admin/core}/utils/HttpExchangeUtils.java | 2 +- .../request/TopicCreateRequestTest.java | 65 --------- .../rocketmq/response/TopicResponseTest.java | 58 -------- .../rocketmq/util/RequestMappingTest.java | 80 ----------- .../rocketmq/util/UrlMappingPatternTest.java | 119 ---------------- eventmesh-runtime/build.gradle | 1 + .../runtime/boot/EventMeshServer.java | 2 +- 51 files changed, 131 insertions(+), 1007 deletions(-) delete mode 100644 eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/Constants.java delete mode 100644 eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/controller/AdminController.java rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/controller/ClientManageController.java (79%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/controller/HttpHandlerManager.java (97%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/AbstractHttpHandler.java (91%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/ConfigurationHandler.java (96%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/DeleteWebHookConfigHandler.java (95%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/EventHandler.java (97%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/GrpcClientHandler.java (96%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/HTTPClientHandler.java (96%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/InsertWebHookConfigHandler.java (95%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/MetricsHandler.java (97%) mode change 100755 => 100644 rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/QueryRecommendEventMeshHandler.java (96%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/QueryWebHookConfigByIdHandler.java (91%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/QueryWebHookConfigByManufacturerHandler.java (93%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/RedirectClientByIpPortHandler.java (97%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/RedirectClientByPathHandler.java (97%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/RedirectClientBySubSystemHandler.java (97%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/RegistryHandler.java (96%) mode change 100755 => 100644 rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/RejectAllClientHandler.java (97%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/RejectClientByIpPortHandler.java (97%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/RejectClientBySubSystemHandler.java (97%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/ShowClientBySystemHandler.java (96%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/ShowClientHandler.java (96%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/ShowListenClientByTopicHandler.java (97%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/TCPClientHandler.java (96%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/TopicHandler.java (96%) delete mode 100644 eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/TopicsHandler.java rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/handler/UpdateWebHookConfigHandler.java (95%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/request/CreateTopicRequest.java (95%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/request/DeleteGrpcClientRequest.java (95%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/request/DeleteHTTPClientRequest.java (95%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/request/DeleteTCPClientRequest.java (95%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/request/DeleteTopicRequest.java (95%) delete mode 100644 eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/TopicCreateRequest.java rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/response/Error.java (95%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/response/GetClientResponse.java (97%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/response/GetConfigurationResponse.java (98%) rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/response/GetMetricsResponse.java (99%) mode change 100755 => 100644 rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/response/GetRegistryResponse.java (97%) mode change 100755 => 100644 delete mode 100644 eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/TopicResponse.java delete mode 100644 eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/util/RequestMapping.java delete mode 100644 eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/util/UrlMappingPattern.java rename {eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin => eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core}/utils/HttpExchangeUtils.java (96%) delete mode 100644 eventmesh-admin/eventmesh-admin-core/src/test/java/org/apache/eventmesh/admin/rocketmq/request/TopicCreateRequestTest.java delete mode 100644 eventmesh-admin/eventmesh-admin-core/src/test/java/org/apache/eventmesh/admin/rocketmq/response/TopicResponseTest.java delete mode 100644 eventmesh-admin/eventmesh-admin-core/src/test/java/org/apache/eventmesh/admin/rocketmq/util/RequestMappingTest.java delete mode 100644 eventmesh-admin/eventmesh-admin-core/src/test/java/org/apache/eventmesh/admin/rocketmq/util/UrlMappingPatternTest.java diff --git a/eventmesh-admin/eventmesh-admin-core/build.gradle b/eventmesh-admin/eventmesh-admin-core/build.gradle index b6b446586e..9947c1c11d 100644 --- a/eventmesh-admin/eventmesh-admin-core/build.gradle +++ b/eventmesh-admin/eventmesh-admin-core/build.gradle @@ -17,16 +17,29 @@ dependencies { - implementation project(":eventmesh-common") + + implementation "io.cloudevents:cloudevents-core" + implementation "io.cloudevents:cloudevents-json-jackson" implementation "org.apache.httpcomponents:httpclient" implementation "com.fasterxml.jackson.core:jackson-databind" implementation "com.fasterxml.jackson.core:jackson-core" implementation "com.fasterxml.jackson.core:jackson-annotations" - compileOnly 'org.projectlombok:lombok' - annotationProcessor 'org.projectlombok:lombok' + implementation project(":eventmesh-common") + implementation project(":eventmesh-admin:eventmesh-admin-rocketmq") + implementation project(":eventmesh-runtime") + implementation project(":eventmesh-webhook:eventmesh-webhook-admin") + implementation project(":eventmesh-webhook:eventmesh-webhook-api") + implementation project(":eventmesh-registry-plugin:eventmesh-registry-api") + implementation project(":eventmesh-metrics-plugin:eventmesh-metrics-api") + + compileOnly "org.projectlombok:lombok" + annotationProcessor "org.projectlombok:lombok" - testImplementation 'org.mockito:mockito-core' - testImplementation 'org.mockito:mockito-inline' + testImplementation "org.mockito:mockito-core" + testImplementation "org.mockito:mockito-inline" + testImplementation "org.powermock:powermock-module-junit4" + testImplementation "org.powermock:powermock-api-mockito2" + testImplementation "commons-io:commons-io" } \ No newline at end of file diff --git a/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/Constants.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/Constants.java deleted file mode 100644 index d3868b01a3..0000000000 --- a/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/Constants.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.admin.core; - -public class Constants { - - public static final String TOPIC_MANAGE_PATH = "/topicManage"; - - public static final String CONTENT_TYPE = "Content-Type"; - - public static final String APPLICATION_JSON = "application/json"; - - public static final String TOPIC_ERROR = "create topic failed! Server side error"; -} diff --git a/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/controller/AdminController.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/controller/AdminController.java deleted file mode 100644 index 11e2edf64d..0000000000 --- a/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/controller/AdminController.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.admin.core.controller; - -import static org.apache.eventmesh.admin.core.Constants.TOPIC_MANAGE_PATH; - -import org.apache.eventmesh.admin.core.handler.TopicsHandler; - -import java.io.IOException; - - -import com.sun.net.httpserver.HttpServer; - -import lombok.extern.slf4j.Slf4j; - -/** - * This class is responsible for managing the admin module. - *

- * It provides a method to run the admin module with the specified {@link HttpServer} - * and handles requests related to topics management. - */ - -@Slf4j -public class AdminController { - - public AdminController() { - } - - /** - * Invoke this method to run the admin module. - * - * @param server A HttpServer is bound to an IP address and port number - * and listens for incoming TCP connections from clients on this address. - * @throws IOException - * @see HttpServer - */ - public void run(HttpServer server) throws IOException { - - // Creates a mapping from API URI path to the exchange handler on this HttpServer. - server.createContext(TOPIC_MANAGE_PATH, new TopicsHandler()); - - log.info("EventMesh-Admin Controller server context created successfully"); - } -} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/controller/ClientManageController.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/controller/ClientManageController.java similarity index 79% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/controller/ClientManageController.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/controller/ClientManageController.java index 4d314bc0f3..856ffce3ab 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/controller/ClientManageController.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/controller/ClientManageController.java @@ -15,32 +15,32 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.controller; - +package org.apache.eventmesh.admin.core.controller; + +import org.apache.eventmesh.admin.core.handler.ConfigurationHandler; +import org.apache.eventmesh.admin.core.handler.DeleteWebHookConfigHandler; +import org.apache.eventmesh.admin.core.handler.EventHandler; +import org.apache.eventmesh.admin.core.handler.GrpcClientHandler; +import org.apache.eventmesh.admin.core.handler.RedirectClientBySubSystemHandler; +import org.apache.eventmesh.admin.core.handler.RegistryHandler; +import org.apache.eventmesh.admin.core.handler.RejectAllClientHandler; +import org.apache.eventmesh.admin.core.handler.RejectClientByIpPortHandler; +import org.apache.eventmesh.admin.core.handler.RejectClientBySubSystemHandler; +import org.apache.eventmesh.admin.core.handler.ShowClientBySystemHandler; +import org.apache.eventmesh.admin.core.handler.ShowClientHandler; +import org.apache.eventmesh.admin.core.handler.ShowListenClientByTopicHandler; +import org.apache.eventmesh.admin.core.handler.TCPClientHandler; +import org.apache.eventmesh.admin.core.handler.TopicHandler; import org.apache.eventmesh.admin.rocketmq.controller.AdminController; -import org.apache.eventmesh.runtime.admin.handler.ConfigurationHandler; -import org.apache.eventmesh.runtime.admin.handler.DeleteWebHookConfigHandler; -import org.apache.eventmesh.runtime.admin.handler.EventHandler; -import org.apache.eventmesh.runtime.admin.handler.GrpcClientHandler; -import org.apache.eventmesh.runtime.admin.handler.HTTPClientHandler; -import org.apache.eventmesh.runtime.admin.handler.InsertWebHookConfigHandler; -import org.apache.eventmesh.runtime.admin.handler.MetricsHandler; -import org.apache.eventmesh.runtime.admin.handler.QueryRecommendEventMeshHandler; -import org.apache.eventmesh.runtime.admin.handler.QueryWebHookConfigByIdHandler; -import org.apache.eventmesh.runtime.admin.handler.QueryWebHookConfigByManufacturerHandler; -import org.apache.eventmesh.runtime.admin.handler.RedirectClientByIpPortHandler; -import org.apache.eventmesh.runtime.admin.handler.RedirectClientByPathHandler; -import org.apache.eventmesh.runtime.admin.handler.RedirectClientBySubSystemHandler; -import org.apache.eventmesh.runtime.admin.handler.RegistryHandler; -import org.apache.eventmesh.runtime.admin.handler.RejectAllClientHandler; -import org.apache.eventmesh.runtime.admin.handler.RejectClientByIpPortHandler; -import org.apache.eventmesh.runtime.admin.handler.RejectClientBySubSystemHandler; -import org.apache.eventmesh.runtime.admin.handler.ShowClientBySystemHandler; -import org.apache.eventmesh.runtime.admin.handler.ShowClientHandler; -import org.apache.eventmesh.runtime.admin.handler.ShowListenClientByTopicHandler; -import org.apache.eventmesh.runtime.admin.handler.TCPClientHandler; -import org.apache.eventmesh.runtime.admin.handler.TopicHandler; -import org.apache.eventmesh.runtime.admin.handler.UpdateWebHookConfigHandler; +import org.apache.eventmesh.admin.core.handler.HTTPClientHandler; +import org.apache.eventmesh.admin.core.handler.InsertWebHookConfigHandler; +import org.apache.eventmesh.admin.core.handler.MetricsHandler; +import org.apache.eventmesh.admin.core.handler.QueryRecommendEventMeshHandler; +import org.apache.eventmesh.admin.core.handler.QueryWebHookConfigByIdHandler; +import org.apache.eventmesh.admin.core.handler.QueryWebHookConfigByManufacturerHandler; +import org.apache.eventmesh.admin.core.handler.RedirectClientByIpPortHandler; +import org.apache.eventmesh.admin.core.handler.RedirectClientByPathHandler; +import org.apache.eventmesh.admin.core.handler.UpdateWebHookConfigHandler; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/controller/HttpHandlerManager.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/controller/HttpHandlerManager.java similarity index 97% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/controller/HttpHandlerManager.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/controller/HttpHandlerManager.java index 47557608f1..1d010a8b42 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/controller/HttpHandlerManager.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/controller/HttpHandlerManager.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.controller; +package org.apache.eventmesh.admin.core.controller; import org.apache.eventmesh.runtime.common.EventHttpHandler; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/AbstractHttpHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/AbstractHttpHandler.java similarity index 91% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/AbstractHttpHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/AbstractHttpHandler.java index e13ce6d771..0594ca08ab 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/AbstractHttpHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/AbstractHttpHandler.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; import com.sun.net.httpserver.HttpHandler; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ConfigurationHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/ConfigurationHandler.java similarity index 96% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ConfigurationHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/ConfigurationHandler.java index a98647803a..083c7cf0fe 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ConfigurationHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/ConfigurationHandler.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.enums.HttpMethod; import org.apache.eventmesh.common.utils.JsonUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; -import org.apache.eventmesh.runtime.admin.response.Error; -import org.apache.eventmesh.runtime.admin.response.GetConfigurationResponse; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.response.Error; +import org.apache.eventmesh.admin.core.response.GetConfigurationResponse; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; import org.apache.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/DeleteWebHookConfigHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/DeleteWebHookConfigHandler.java similarity index 95% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/DeleteWebHookConfigHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/DeleteWebHookConfigHandler.java index b43df2fcff..d0b4ed2e77 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/DeleteWebHookConfigHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/DeleteWebHookConfigHandler.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.common.utils.NetUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.webhook.api.WebHookConfig; import org.apache.eventmesh.webhook.api.WebHookConfigOperation; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/EventHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/EventHandler.java similarity index 97% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/EventHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/EventHandler.java index 66fd824ab6..f32fe30731 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/EventHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/EventHandler.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.enums.HttpMethod; import org.apache.eventmesh.common.utils.JsonUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; -import org.apache.eventmesh.runtime.admin.response.Error; -import org.apache.eventmesh.runtime.admin.utils.HttpExchangeUtils; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.response.Error; +import org.apache.eventmesh.admin.core.utils.HttpExchangeUtils; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.plugin.MQAdminWrapper; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/GrpcClientHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/GrpcClientHandler.java similarity index 96% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/GrpcClientHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/GrpcClientHandler.java index 6d6dac03dd..18f7dd415f 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/GrpcClientHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/GrpcClientHandler.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; +import org.apache.eventmesh.admin.core.request.DeleteGrpcClientRequest; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.enums.HttpMethod; import org.apache.eventmesh.common.utils.JsonUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; -import org.apache.eventmesh.runtime.admin.request.DeleteGrpcClientRequest; -import org.apache.eventmesh.runtime.admin.response.Error; -import org.apache.eventmesh.runtime.admin.response.GetClientResponse; -import org.apache.eventmesh.runtime.admin.utils.HttpExchangeUtils; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.response.Error; +import org.apache.eventmesh.admin.core.response.GetClientResponse; +import org.apache.eventmesh.admin.core.utils.HttpExchangeUtils; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.constants.EventMeshConstants; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/HTTPClientHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/HTTPClientHandler.java similarity index 96% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/HTTPClientHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/HTTPClientHandler.java index 41a6a980b0..27c72fda4e 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/HTTPClientHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/HTTPClientHandler.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.request.DeleteHTTPClientRequest; +import org.apache.eventmesh.admin.core.response.Error; +import org.apache.eventmesh.admin.core.response.GetClientResponse; +import org.apache.eventmesh.admin.core.utils.HttpExchangeUtils; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.enums.HttpMethod; import org.apache.eventmesh.common.utils.JsonUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; -import org.apache.eventmesh.runtime.admin.request.DeleteHTTPClientRequest; -import org.apache.eventmesh.runtime.admin.response.Error; -import org.apache.eventmesh.runtime.admin.response.GetClientResponse; -import org.apache.eventmesh.runtime.admin.utils.HttpExchangeUtils; import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.constants.EventMeshConstants; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/InsertWebHookConfigHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/InsertWebHookConfigHandler.java similarity index 95% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/InsertWebHookConfigHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/InsertWebHookConfigHandler.java index dfbfd9f26d..1d59d7c838 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/InsertWebHookConfigHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/InsertWebHookConfigHandler.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.common.utils.NetUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.webhook.api.WebHookConfig; import org.apache.eventmesh.webhook.api.WebHookConfigOperation; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/MetricsHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/MetricsHandler.java old mode 100755 new mode 100644 similarity index 97% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/MetricsHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/MetricsHandler.java index e93eeb4b29..24496c4d9e --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/MetricsHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/MetricsHandler.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.response.Error; +import org.apache.eventmesh.admin.core.response.GetMetricsResponse; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.enums.HttpMethod; import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.metrics.api.model.HttpSummaryMetrics; import org.apache.eventmesh.metrics.api.model.TcpSummaryMetrics; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; -import org.apache.eventmesh.runtime.admin.response.Error; -import org.apache.eventmesh.runtime.admin.response.GetMetricsResponse; import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer; import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; import org.apache.eventmesh.runtime.common.EventHttpHandler; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/QueryRecommendEventMeshHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/QueryRecommendEventMeshHandler.java similarity index 96% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/QueryRecommendEventMeshHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/QueryRecommendEventMeshHandler.java index 18741c7e50..683f13f9f2 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/QueryRecommendEventMeshHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/QueryRecommendEventMeshHandler.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.utils.NetUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.constants.EventMeshConstants; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/QueryWebHookConfigByIdHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/QueryWebHookConfigByIdHandler.java similarity index 91% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/QueryWebHookConfigByIdHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/QueryWebHookConfigByIdHandler.java index 35ea9a6714..c658b9029a 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/QueryWebHookConfigByIdHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/QueryWebHookConfigByIdHandler.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; import static org.apache.eventmesh.runtime.constants.EventMeshConstants.APPLICATION_JSON; import static org.apache.eventmesh.runtime.constants.EventMeshConstants.CONTENT_TYPE; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.common.utils.NetUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.webhook.api.WebHookConfig; import org.apache.eventmesh.webhook.api.WebHookConfigOperation; @@ -52,7 +52,7 @@ public QueryWebHookConfigByIdHandler(WebHookConfigOperation operation, HttpHandl @Override public void handle(HttpExchange httpExchange) throws IOException { NetUtils.sendSuccessResponseHeaders(httpExchange); - httpExchange.getResponseHeaders().add(CONTENT_TYPE, APPLICATION_JSON); + httpExchange.getResponseHeaders().add(EventMeshConstants.CONTENT_TYPE, EventMeshConstants.APPLICATION_JSON); // get requestBody and resolve to WebHookConfig String requestBody = NetUtils.parsePostBody(httpExchange); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/QueryWebHookConfigByManufacturerHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/QueryWebHookConfigByManufacturerHandler.java similarity index 93% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/QueryWebHookConfigByManufacturerHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/QueryWebHookConfigByManufacturerHandler.java index 3a16cce36c..d2da37073b 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/QueryWebHookConfigByManufacturerHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/QueryWebHookConfigByManufacturerHandler.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; import static org.apache.eventmesh.runtime.constants.EventMeshConstants.APPLICATION_JSON; import static org.apache.eventmesh.runtime.constants.EventMeshConstants.CONTENT_TYPE; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.common.utils.NetUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.webhook.api.WebHookConfig; import org.apache.eventmesh.webhook.api.WebHookConfigOperation; @@ -61,7 +61,7 @@ public void handle(HttpExchange httpExchange) throws IOException { Objects.requireNonNull(httpExchange, "httpExchange can not be null"); NetUtils.sendSuccessResponseHeaders(httpExchange); - httpExchange.getResponseHeaders().add(CONTENT_TYPE, APPLICATION_JSON); + httpExchange.getResponseHeaders().add(EventMeshConstants.CONTENT_TYPE, EventMeshConstants.APPLICATION_JSON); // get requestBody and resolve to WebHookConfig JsonNode node = JsonUtils.getJsonNode(NetUtils.parsePostBody(httpExchange)); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RedirectClientByIpPortHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RedirectClientByIpPortHandler.java similarity index 97% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RedirectClientByIpPortHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RedirectClientByIpPortHandler.java index b886e8b62d..ef37b2fddb 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RedirectClientByIpPortHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RedirectClientByIpPortHandler.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.utils.NetUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.constants.EventMeshConstants; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RedirectClientByPathHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RedirectClientByPathHandler.java similarity index 97% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RedirectClientByPathHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RedirectClientByPathHandler.java index a4cbaf1662..28418fc8a0 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RedirectClientByPathHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RedirectClientByPathHandler.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.utils.NetUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.constants.EventMeshConstants; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RedirectClientBySubSystemHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RedirectClientBySubSystemHandler.java similarity index 97% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RedirectClientBySubSystemHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RedirectClientBySubSystemHandler.java index 42ecf69d6c..115adc2074 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RedirectClientBySubSystemHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RedirectClientBySubSystemHandler.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.utils.NetUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.constants.EventMeshConstants; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RegistryHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RegistryHandler.java old mode 100755 new mode 100644 similarity index 96% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RegistryHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RegistryHandler.java index e3bd4c2f94..885ffee346 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RegistryHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RegistryHandler.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; +import org.apache.eventmesh.admin.core.response.GetRegistryResponse; import org.apache.eventmesh.api.registry.dto.EventMeshDataInfo; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.enums.HttpMethod; import org.apache.eventmesh.common.utils.JsonUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; -import org.apache.eventmesh.runtime.admin.response.Error; -import org.apache.eventmesh.runtime.admin.response.GetRegistryResponse; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.response.Error; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.registry.Registry; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectAllClientHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RejectAllClientHandler.java similarity index 97% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectAllClientHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RejectAllClientHandler.java index 449c1033a4..2cada29052 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectAllClientHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RejectAllClientHandler.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.utils.NetUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcp2Client; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectClientByIpPortHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RejectClientByIpPortHandler.java similarity index 97% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectClientByIpPortHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RejectClientByIpPortHandler.java index 77722daa81..da9524e222 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectClientByIpPortHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RejectClientByIpPortHandler.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.utils.NetUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.constants.EventMeshConstants; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectClientBySubSystemHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RejectClientBySubSystemHandler.java similarity index 97% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectClientBySubSystemHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RejectClientBySubSystemHandler.java index 16e155c470..42140173f6 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RejectClientBySubSystemHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/RejectClientBySubSystemHandler.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.utils.NetUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.constants.EventMeshConstants; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ShowClientBySystemHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/ShowClientBySystemHandler.java similarity index 96% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ShowClientBySystemHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/ShowClientBySystemHandler.java index 58168a0d4c..b6aea673e6 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ShowClientBySystemHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/ShowClientBySystemHandler.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.common.utils.NetUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.constants.EventMeshConstants; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ShowClientHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/ShowClientHandler.java similarity index 96% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ShowClientHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/ShowClientHandler.java index cbfa2a2bf2..71a5985466 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ShowClientHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/ShowClientHandler.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.utils.NetUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.core.protocol.tcp.client.group.ClientSessionGroupMapping; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ShowListenClientByTopicHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/ShowListenClientByTopicHandler.java similarity index 97% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ShowListenClientByTopicHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/ShowListenClientByTopicHandler.java index 8d9376f462..f8aed3ba4e 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/ShowListenClientByTopicHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/ShowListenClientByTopicHandler.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.common.utils.NetUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.constants.EventMeshConstants; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/TCPClientHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/TCPClientHandler.java similarity index 96% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/TCPClientHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/TCPClientHandler.java index d85d359aef..93c9132fd4 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/TCPClientHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/TCPClientHandler.java @@ -15,17 +15,17 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; +import org.apache.eventmesh.admin.core.request.DeleteTCPClientRequest; +import org.apache.eventmesh.admin.core.utils.HttpExchangeUtils; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.enums.HttpMethod; import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.common.utils.JsonUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; -import org.apache.eventmesh.runtime.admin.request.DeleteTCPClientRequest; -import org.apache.eventmesh.runtime.admin.response.Error; -import org.apache.eventmesh.runtime.admin.response.GetClientResponse; -import org.apache.eventmesh.runtime.admin.utils.HttpExchangeUtils; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.response.Error; +import org.apache.eventmesh.admin.core.response.GetClientResponse; import org.apache.eventmesh.runtime.boot.EventMeshTCPServer; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.constants.EventMeshConstants; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/TopicHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/TopicHandler.java similarity index 96% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/TopicHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/TopicHandler.java index 920f9b732b..47804e50db 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/TopicHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/TopicHandler.java @@ -15,17 +15,17 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; +import org.apache.eventmesh.admin.core.request.CreateTopicRequest; +import org.apache.eventmesh.admin.core.request.DeleteTopicRequest; +import org.apache.eventmesh.admin.core.utils.HttpExchangeUtils; import org.apache.eventmesh.api.admin.TopicProperties; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.enums.HttpMethod; import org.apache.eventmesh.common.utils.JsonUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; -import org.apache.eventmesh.runtime.admin.request.CreateTopicRequest; -import org.apache.eventmesh.runtime.admin.request.DeleteTopicRequest; -import org.apache.eventmesh.runtime.admin.response.Error; -import org.apache.eventmesh.runtime.admin.utils.HttpExchangeUtils; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.response.Error; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.plugin.MQAdminWrapper; diff --git a/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/TopicsHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/TopicsHandler.java deleted file mode 100644 index b0ead03443..0000000000 --- a/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/TopicsHandler.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.admin.core.handler; - -import org.apache.eventmesh.admin.core.request.TopicCreateRequest; -import org.apache.eventmesh.admin.core.response.TopicResponse; -import org.apache.eventmesh.admin.core.util.RequestMapping; -import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.utils.JsonUtils; -import org.apache.eventmesh.common.utils.NetUtils; - -import org.apache.commons.lang3.StringUtils; - -import java.io.IOException; -import java.io.OutputStream; - -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; - -import lombok.extern.slf4j.Slf4j; - -/** - * This class is responsible for handling HTTP requests related to topics. - *

- * It implements the {@link HttpHandler} interface to process incoming requests, - * which is used by the {@linkplain com.sun.net.httpserver.HttpServer HttpServer}. - *

- * It uses the {@link RequestMapping} class to match the request URL and the HTTP method. - *

- * It uses the {@link TopicCreateRequest} class to parse the request body - * and the {@link TopicResponse} class to create the response. - * - * @see HttpHandler - */ - -@Slf4j -public class TopicsHandler implements HttpHandler { - - /** - * Handles the HTTP request for creating topics. - * - * @param httpExchange the exchange containing the request from the client and used to send the response - * @throws IOException if an I/O error occurs - * @see HttpHandler#handle(HttpExchange) - */ - @Override - public void handle(HttpExchange httpExchange) throws IOException { - - // If the request matches, then create a new topic. - if (RequestMapping.postMapping(org.apache.eventmesh.admin.core.Constants.TOPIC_MANAGE_PATH, httpExchange)) { - createTopicHandler(httpExchange); - return; - } - - // Otherwise, it prepares an error response and sends it back to the client. - OutputStream out = httpExchange.getResponseBody(); - httpExchange.sendResponseHeaders(500, 0); - String result = String.format("Please check your request url: %s", httpExchange.getRequestURI()); - log.error(result); - // Write the response data. - out.write(result.getBytes(Constants.DEFAULT_CHARSET)); - } - - /** - * Handles the creation of a new topic. - * - * @param httpExchange the exchange containing the request from the client and used to send the response - * @throws IOException if an I/O error occurs - */ - public void createTopicHandler(HttpExchange httpExchange) throws IOException { - String result; - try (OutputStream out = httpExchange.getResponseBody()) { - // Parses the request body into a TopicCreateRequest object. - String params = NetUtils.parsePostBody(httpExchange); - TopicCreateRequest topicCreateRequest = - JsonUtils.parseObject(params, TopicCreateRequest.class); - // Gets the topic name from the request body. - String topic = topicCreateRequest.getTopic(); - - // If the topic name is empty, then returns an error message. - if (StringUtils.isBlank(topic)) { - result = "Create topic failed. Parameter topic not found."; - log.error(result); - out.write(result.getBytes(Constants.DEFAULT_CHARSET)); - return; - } - - //TBD: A new rocketmq service will be implemented for creating topics - TopicResponse topicResponse = null; // Temporary variable for topic response - if (topicResponse != null) { - log.info("create a new topic: {}", topic); - httpExchange.getResponseHeaders().add( - org.apache.eventmesh.admin.core.Constants.CONTENT_TYPE, org.apache.eventmesh.admin.core.Constants.APPLICATION_JSON); - NetUtils.sendSuccessResponseHeaders(httpExchange); - result = JsonUtils.toJSONString(topicResponse); - log.info(result); - out.write(result.getBytes(Constants.DEFAULT_CHARSET)); - } else { - // If the topic creation fails, then returns an error message. - httpExchange.sendResponseHeaders(500, 0); - result = org.apache.eventmesh.admin.core.Constants.TOPIC_ERROR; - log.error(result); - out.write(result.getBytes(Constants.DEFAULT_CHARSET)); - } - } catch (Exception e) { - // If an exception occurs, then returns an error message. - httpExchange.getResponseHeaders().add( - org.apache.eventmesh.admin.core.Constants.CONTENT_TYPE, org.apache.eventmesh.admin.core.Constants.APPLICATION_JSON); - httpExchange.sendResponseHeaders(500, 0); - result = org.apache.eventmesh.admin.core.Constants.TOPIC_ERROR; - log.error(result, e); - } - } - -} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/UpdateWebHookConfigHandler.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/UpdateWebHookConfigHandler.java similarity index 95% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/UpdateWebHookConfigHandler.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/UpdateWebHookConfigHandler.java index 2990cd9ba9..f4b7a13368 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/UpdateWebHookConfigHandler.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/handler/UpdateWebHookConfigHandler.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.handler; +package org.apache.eventmesh.admin.core.handler; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.common.utils.NetUtils; -import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; +import org.apache.eventmesh.admin.core.controller.HttpHandlerManager; import org.apache.eventmesh.runtime.common.EventHttpHandler; import org.apache.eventmesh.webhook.api.WebHookConfig; import org.apache.eventmesh.webhook.api.WebHookConfigOperation; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/request/CreateTopicRequest.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/CreateTopicRequest.java similarity index 95% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/request/CreateTopicRequest.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/CreateTopicRequest.java index 28f121a796..74b52bfee8 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/request/CreateTopicRequest.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/CreateTopicRequest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.request; +package org.apache.eventmesh.admin.core.request; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/request/DeleteGrpcClientRequest.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/DeleteGrpcClientRequest.java similarity index 95% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/request/DeleteGrpcClientRequest.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/DeleteGrpcClientRequest.java index e8eb265584..c72ef50385 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/request/DeleteGrpcClientRequest.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/DeleteGrpcClientRequest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.request; +package org.apache.eventmesh.admin.core.request; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/request/DeleteHTTPClientRequest.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/DeleteHTTPClientRequest.java similarity index 95% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/request/DeleteHTTPClientRequest.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/DeleteHTTPClientRequest.java index 1561bb3911..f09b013cbd 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/request/DeleteHTTPClientRequest.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/DeleteHTTPClientRequest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.request; +package org.apache.eventmesh.admin.core.request; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/request/DeleteTCPClientRequest.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/DeleteTCPClientRequest.java similarity index 95% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/request/DeleteTCPClientRequest.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/DeleteTCPClientRequest.java index 07ff93551c..fc429b3794 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/request/DeleteTCPClientRequest.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/DeleteTCPClientRequest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.request; +package org.apache.eventmesh.admin.core.request; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/request/DeleteTopicRequest.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/DeleteTopicRequest.java similarity index 95% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/request/DeleteTopicRequest.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/DeleteTopicRequest.java index aa6d29339c..81b6790b58 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/request/DeleteTopicRequest.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/DeleteTopicRequest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.request; +package org.apache.eventmesh.admin.core.request; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/TopicCreateRequest.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/TopicCreateRequest.java deleted file mode 100644 index b79c0dd8cf..0000000000 --- a/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/request/TopicCreateRequest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.admin.core.request; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A data transfer object (DTO) that represents a request to create a new topic. - *

- * This class provides a convenient way to encapsulate the topic information when creating a new topic. - *

- * Empty or null values will not be included in the serialized JSON. - *

- * Any unknown properties will be ignored when deserializing JSON into this class. - *

- * Example usage: - *

- * String params = NetUtils.parsePostBody(httpExchange);
- * TopicCreateRequest topicCreateRequest = JsonUtils.parseObject(params, TopicCreateRequest.class);
- * String topic = topicCreateRequest.getTopic();
- * topicCreateRequest.setTopic("UpdatedTopic");
- * 
- */ - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonIgnoreProperties(ignoreUnknown = true) -public class TopicCreateRequest { - - private String topic; - - /** - * Constructs a new instance of {@link TopicCreateRequest}. - * - * @param topic the topic for the request - */ - @JsonCreator - public TopicCreateRequest(@JsonProperty("topic") String topic) { - this.topic = topic; - } - - public String getTopic() { - return this.topic; - } - - public void setTopic(String topic) { - this.topic = topic; - } - -} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/response/Error.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/Error.java similarity index 95% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/response/Error.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/Error.java index 4b03a07ba8..86b0e1166f 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/response/Error.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/Error.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.response; +package org.apache.eventmesh.admin.core.response; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/response/GetClientResponse.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/GetClientResponse.java similarity index 97% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/response/GetClientResponse.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/GetClientResponse.java index 8093704c56..7253a08fce 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/response/GetClientResponse.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/GetClientResponse.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.response; +package org.apache.eventmesh.admin.core.response; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/response/GetConfigurationResponse.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/GetConfigurationResponse.java similarity index 98% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/response/GetConfigurationResponse.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/GetConfigurationResponse.java index b381c2f651..d4fdc422d9 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/response/GetConfigurationResponse.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/GetConfigurationResponse.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.response; +package org.apache.eventmesh.admin.core.response; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/response/GetMetricsResponse.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/GetMetricsResponse.java old mode 100755 new mode 100644 similarity index 99% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/response/GetMetricsResponse.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/GetMetricsResponse.java index 86f4ed16ac..a3d36a27af --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/response/GetMetricsResponse.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/GetMetricsResponse.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.response; +package org.apache.eventmesh.admin.core.response; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/response/GetRegistryResponse.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/GetRegistryResponse.java old mode 100755 new mode 100644 similarity index 97% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/response/GetRegistryResponse.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/GetRegistryResponse.java index 2a2806a8b9..9fca39591f --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/response/GetRegistryResponse.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/GetRegistryResponse.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.response; +package org.apache.eventmesh.admin.core.response; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/TopicResponse.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/TopicResponse.java deleted file mode 100644 index e347e76206..0000000000 --- a/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/response/TopicResponse.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.admin.core.response; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A data transfer object (DTO) that represents a response containing a topic and its creation time. - *

- * It includes the values returned upon the creation of a new topic, an update to an existing topic, - * or the retrieval of a topic's details. - *

- * It is used to encapsulate the topic information being sent to the client from the server. - */ - -public class TopicResponse { - - private String topic; - private String createdTime; - - @JsonCreator - public TopicResponse(@JsonProperty("topic") String topic, - @JsonProperty("created_time") String createdTime) { - super(); - this.topic = topic; - this.createdTime = createdTime; - } - - @JsonProperty("topic") - public String getTopic() { - return this.topic; - } - - @JsonProperty("topic") - public void setTopic(String topic) { - this.topic = topic; - } - - @JsonProperty("created_time") - public String getCreatedTime() { - return createdTime; - } - - @JsonProperty("created_time") - public void setCreatedTime(String createdTime) { - this.createdTime = createdTime; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("TopicResponse {topic=").append(this.topic).append(",").append("created_time=").append(this.createdTime).append("}"); - return sb.toString(); - } - -} diff --git a/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/util/RequestMapping.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/util/RequestMapping.java deleted file mode 100644 index a8aa64e6aa..0000000000 --- a/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/util/RequestMapping.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.admin.core.util; - -import org.apache.eventmesh.common.enums.HttpMethod; - -import com.sun.net.httpserver.HttpExchange; - -import lombok.experimental.UtilityClass; - -/** - * This class provides utility methods for handling HTTP request mappings. - */ - -@UtilityClass -public class RequestMapping { - - /** - * Performs a POST mapping for a specific URL. - * - * @param value the URL pattern to match - * @param httpExchange the exchange containing the request from the client and used to send the response - * @return {@code true} if the URL pattern matches and the HTTP method is POST, {@code false} otherwise - */ - public boolean postMapping(String value, HttpExchange httpExchange) { - return isUrlMatch(value, httpExchange, HttpMethod.POST.name()); - } - - /** - * Performs a GET mapping for a specific URL. - * - * @param value the URL pattern to match - * @param httpExchange the exchange containing the request from the client and used to send the response - * @return {@code true} if the URL pattern matches and the HTTP method is GET, {@code false} otherwise - */ - public boolean getMapping(String value, HttpExchange httpExchange) { - return isUrlMatch(value, httpExchange, HttpMethod.GET.name()); - } - - /** - * Performs a PUT mapping for a specific URL. - * - * @param value the URL pattern to match - * @param httpExchange the exchange containing the request from the client and used to send the response - * @return {@code true} if the URL pattern matches and the HTTP method is PUT, {@code false} otherwise - */ - public boolean putMapping(String value, HttpExchange httpExchange) { - return isUrlMatch(value, httpExchange, HttpMethod.PUT.name()); - } - - /** - * Performs a DELETE mapping for a specific URL. - * - * @param value the URL pattern to match - * @param httpExchange the exchange containing the request from the client and used to send the response - * @return {@code true} if the URL pattern matches and the HTTP method is DELETE, {@code false} otherwise - */ - public boolean deleteMapping(String value, HttpExchange httpExchange) { - return isUrlMatch(value, httpExchange, HttpMethod.DELETE.name()); - } - - /** - * Checks if the URL pattern matches the request URI and the HTTP method is the specified method type. - * - * @param value the URL pattern to match - * @param httpExchange the exchange containing the request from the client and used to send the response - * @param methodType the HTTP method type to check against - * @return {@code true} if the URL pattern matches and the HTTP method is the specified method type, {@code false} otherwise - */ - private boolean isUrlMatch(String value, HttpExchange httpExchange, String methodType) { - if (methodType.equalsIgnoreCase(httpExchange.getRequestMethod())) { - String requestUri = httpExchange.getRequestURI().getPath(); - UrlMappingPattern matcher = new UrlMappingPattern(value); - return matcher.matches(requestUri); - } - return false; - } - -} diff --git a/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/util/UrlMappingPattern.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/util/UrlMappingPattern.java deleted file mode 100644 index f8a8fa83ea..0000000000 --- a/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/util/UrlMappingPattern.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.admin.core.util; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Represents a URL mapping pattern for routing purposes. - * The pattern can include variable path parameters or query strings. - */ - -public class UrlMappingPattern { - - private static final String URL_PARAMETER_REGEX = "\\{(\\w*?)\\}"; - - private static final String URL_PARAMETER_MATCH_REGEX = - "\\([%\\\\w-.\\\\~!\\$&'\\\\(\\\\)\\\\*\\\\+,;=:\\\\[\\\\]@]+?\\)"; - - private static final Pattern URL_PARAMETER_PATTERN = Pattern.compile(URL_PARAMETER_REGEX); - - private static final String URL_FORMAT_REGEX = "(?:\\.\\{format\\})$"; - - private static final String URL_FORMAT_MATCH_REGEX = "(?:\\\\.\\([\\\\w%]+?\\))?"; - - private static final String URL_QUERY_STRING_REGEX = "(?:\\?.*?)?$"; - - private String urlMappingPattern; - - private Pattern compiledUrlMappingPattern; - - private List paramNames = new ArrayList<>(); - - public UrlMappingPattern(String pattern) { - this.urlMappingPattern = pattern; - compile(); - } - - public String getMappingPattern() { - return urlMappingPattern.replaceFirst(URL_FORMAT_REGEX, ""); - } - - /** - * Extracts path parameters from the given URL and returns a {@link Map} of parameter names to values. - * - * @param url the URL from which to extract path parameters - * @return a {@link Map} containing path parameter names and their corresponding values, - * or null if the URL does not match the defined URL mapping pattern - */ - public Map extractPathParameterValues(String url) { - Matcher matcher = compiledUrlMappingPattern.matcher(url); - if (matcher.matches()) { - return extractParameters(matcher); - } - return null; - } - - public boolean matches(String url) { - return (extractPathParameterValues(url) != null); - } - - public void compile() { - acquireParamNames(); - String parsedPattern = urlMappingPattern.replaceFirst(URL_FORMAT_REGEX, URL_FORMAT_MATCH_REGEX); - parsedPattern = parsedPattern.replaceAll(URL_PARAMETER_REGEX, URL_PARAMETER_MATCH_REGEX); - this.compiledUrlMappingPattern = Pattern.compile(parsedPattern + URL_QUERY_STRING_REGEX); - } - - private void acquireParamNames() { - Matcher m = URL_PARAMETER_PATTERN.matcher(urlMappingPattern); - while (m.find()) { - paramNames.add(m.group(1)); - } - } - - /** - * Extracts parameters from the provided {@link Matcher} object and returns a {@link Map} of parameter names to values. - * - * @param matcher the Matcher object used to match and capture parameter values - * @return a {@link Map} containing parameter names and their corresponding values - */ - private Map extractParameters(Matcher matcher) { - Map values = new HashMap<>((int) (matcher.groupCount() / 0.75f + 1)); - for (int i = 0; i < matcher.groupCount(); i++) { - String value = matcher.group(i + 1); - - if (value != null) { - values.put(paramNames.get(i), value); - } - } - return values; - } - - public List getParamNames() { - return Collections.unmodifiableList(paramNames); - } -} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/utils/HttpExchangeUtils.java b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/utils/HttpExchangeUtils.java similarity index 96% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/utils/HttpExchangeUtils.java rename to eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/utils/HttpExchangeUtils.java index 67479c8c2f..5c7c466fce 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/utils/HttpExchangeUtils.java +++ b/eventmesh-admin/eventmesh-admin-core/src/main/java/org/apache/eventmesh/admin/core/utils/HttpExchangeUtils.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.admin.utils; +package org.apache.eventmesh.admin.core.utils; import java.io.BufferedReader; import java.io.IOException; diff --git a/eventmesh-admin/eventmesh-admin-core/src/test/java/org/apache/eventmesh/admin/rocketmq/request/TopicCreateRequestTest.java b/eventmesh-admin/eventmesh-admin-core/src/test/java/org/apache/eventmesh/admin/rocketmq/request/TopicCreateRequestTest.java deleted file mode 100644 index 3246e9bf62..0000000000 --- a/eventmesh-admin/eventmesh-admin-core/src/test/java/org/apache/eventmesh/admin/rocketmq/request/TopicCreateRequestTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.admin.rocketmq.request; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.apache.eventmesh.admin.core.request.TopicCreateRequest; - -import org.junit.Test; - -import com.fasterxml.jackson.databind.ObjectMapper; - -public class TopicCreateRequestTest { - - @Test - public void testTopicCreateRequest() { - String name = "testTopic"; - TopicCreateRequest topicCreateRequest = new TopicCreateRequest(name); - - assertEquals(name, topicCreateRequest.getTopic()); - } - - @Test - public void testTopicCreateRequestSetName() { - TopicCreateRequest topicCreateRequest = new TopicCreateRequest(null); - assertNull(topicCreateRequest.getTopic()); - - String name = "testTopic"; - topicCreateRequest.setTopic(name); - assertEquals(name, topicCreateRequest.getTopic()); - } - - @Test - public void testTopicCreateRequestSerialization() throws Exception { - String topic = "testTopic"; - TopicCreateRequest topicCreateRequest = new TopicCreateRequest(topic); - - ObjectMapper objectMapper = new ObjectMapper(); - String json = objectMapper.writeValueAsString(topicCreateRequest); - - assertTrue(json.contains("topic")); - - TopicCreateRequest deserializedRequest = objectMapper.readValue(json, TopicCreateRequest.class); - - assertEquals(topic, deserializedRequest.getTopic()); - } - -} diff --git a/eventmesh-admin/eventmesh-admin-core/src/test/java/org/apache/eventmesh/admin/rocketmq/response/TopicResponseTest.java b/eventmesh-admin/eventmesh-admin-core/src/test/java/org/apache/eventmesh/admin/rocketmq/response/TopicResponseTest.java deleted file mode 100644 index 95044a804e..0000000000 --- a/eventmesh-admin/eventmesh-admin-core/src/test/java/org/apache/eventmesh/admin/rocketmq/response/TopicResponseTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.admin.rocketmq.response; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.apache.eventmesh.admin.core.response.TopicResponse; - -import org.junit.Test; - -import com.fasterxml.jackson.databind.ObjectMapper; - -public class TopicResponseTest { - - @Test - public void testTopicResponse() { - String topic = "testtopic"; - String createdTime = "2023-05-17 10:30:00"; - TopicResponse topicResponse = new TopicResponse(topic, createdTime); - - assertEquals(topic, topicResponse.getTopic()); - assertEquals(createdTime, topicResponse.getCreatedTime()); - } - - @Test - public void testTopicResponseSerialization() throws Exception { - String topic = "testtopic"; - String createdTime = "2023-05-17 10:30:00"; - TopicResponse topicResponse = new TopicResponse(topic, createdTime); - - ObjectMapper objectMapper = new ObjectMapper(); - String json = objectMapper.writeValueAsString(topicResponse); - - assertTrue(json.contains("topic")); - assertTrue(json.contains("created_time")); - - TopicResponse deserializedResponse = objectMapper.readValue(json, TopicResponse.class); - - assertEquals(topic, deserializedResponse.getTopic()); - assertEquals(createdTime, deserializedResponse.getCreatedTime()); - } -} diff --git a/eventmesh-admin/eventmesh-admin-core/src/test/java/org/apache/eventmesh/admin/rocketmq/util/RequestMappingTest.java b/eventmesh-admin/eventmesh-admin-core/src/test/java/org/apache/eventmesh/admin/rocketmq/util/RequestMappingTest.java deleted file mode 100644 index b1df9c5f78..0000000000 --- a/eventmesh-admin/eventmesh-admin-core/src/test/java/org/apache/eventmesh/admin/rocketmq/util/RequestMappingTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.admin.rocketmq.util; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.apache.eventmesh.admin.core.util.RequestMapping; -import org.apache.eventmesh.common.enums.HttpMethod; - -import java.net.URI; -import java.net.URISyntaxException; - -import org.junit.Test; - -import com.sun.net.httpserver.HttpExchange; - - -public class RequestMappingTest { - - @Test - public void testPostMapping() throws URISyntaxException { - HttpExchange httpExchange = mock(HttpExchange.class); - when(httpExchange.getRequestMethod()).thenReturn(HttpMethod.POST.name()); - URI requestUri = new URI("/test/123"); - when(httpExchange.getRequestURI()).thenReturn(requestUri); - - boolean result = RequestMapping.postMapping("/test/{value}", httpExchange); - assertEquals(true, result); - } - - @Test - public void testGetMapping() throws URISyntaxException { - HttpExchange httpExchange = mock(HttpExchange.class); - when(httpExchange.getRequestMethod()).thenReturn(HttpMethod.GET.name()); - URI requestUri = new URI("/test/123"); - when(httpExchange.getRequestURI()).thenReturn(requestUri); - - boolean result = RequestMapping.getMapping("/test/{value}", httpExchange); - assertEquals(true, result); - } - - @Test - public void testPutMapping() throws URISyntaxException { - HttpExchange httpExchange = mock(HttpExchange.class); - when(httpExchange.getRequestMethod()).thenReturn(HttpMethod.PUT.name()); - URI requestUri = new URI("/test/123"); - when(httpExchange.getRequestURI()).thenReturn(requestUri); - - boolean result = RequestMapping.putMapping("/test/{value}", httpExchange); - assertEquals(true, result); - } - - @Test - public void testDeleteMapping() throws URISyntaxException { - HttpExchange httpExchange = mock(HttpExchange.class); - when(httpExchange.getRequestMethod()).thenReturn(HttpMethod.DELETE.name()); - URI requestUri = new URI("/test/123"); - when(httpExchange.getRequestURI()).thenReturn(requestUri); - - boolean result = RequestMapping.deleteMapping("/test/{value}", httpExchange); - assertEquals(true, result); - } -} diff --git a/eventmesh-admin/eventmesh-admin-core/src/test/java/org/apache/eventmesh/admin/rocketmq/util/UrlMappingPatternTest.java b/eventmesh-admin/eventmesh-admin-core/src/test/java/org/apache/eventmesh/admin/rocketmq/util/UrlMappingPatternTest.java deleted file mode 100644 index f0c20b9f3c..0000000000 --- a/eventmesh-admin/eventmesh-admin-core/src/test/java/org/apache/eventmesh/admin/rocketmq/util/UrlMappingPatternTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.admin.rocketmq.util; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.apache.eventmesh.admin.core.util.UrlMappingPattern; - -import java.lang.reflect.Field; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.junit.Before; -import org.junit.Test; - -public class UrlMappingPatternTest { - - private static final String TEST_URL_MAPPING_PATTERN = "/test/{param1}/path/{param2}"; - - private TestUrlMappingPattern urlMappingPattern; - - @Before - public void setUp() { - urlMappingPattern = new TestUrlMappingPattern(TEST_URL_MAPPING_PATTERN); - } - - @Test - public void testGetMappingPattern() { - assertEquals("/test/{param1}/path/{param2}", urlMappingPattern.getMappingPattern()); - } - - @Test - public void testExtractPathParameterValues() { - String testUrl = "/test/123/path/456"; - Matcher mockMatcher = mock(Matcher.class); - when(mockMatcher.matches()).thenReturn(true); - when(mockMatcher.groupCount()).thenReturn(2); - when(mockMatcher.group(1)).thenReturn("123"); - when(mockMatcher.group(2)).thenReturn("456"); - when(urlMappingPattern.compiledUrlMappingPattern.matcher(testUrl)).thenReturn(mockMatcher); - Map parameterValues = urlMappingPattern.extractPathParameterValues(testUrl); - assertEquals("123", parameterValues.get("param1")); - assertEquals("456", parameterValues.get("param2")); - } - - @Test - public void testExtractPathParameterValuesWithNoMatch() { - String testUrl = "/test/123/456"; - Matcher mockMatcher = mock(Matcher.class); - when(mockMatcher.matches()).thenReturn(false); - when(urlMappingPattern.compiledUrlMappingPattern.matcher(testUrl)).thenReturn(mockMatcher); - assertNull(urlMappingPattern.extractPathParameterValues(testUrl)); - } - - @Test - public void testMatches() { - String testUrl = "/test/123/path/456"; - Matcher mockMatcher = mock(Matcher.class); - when(mockMatcher.matches()).thenReturn(true); - when(urlMappingPattern.compiledUrlMappingPattern.matcher(testUrl)).thenReturn(mockMatcher); - assertTrue(urlMappingPattern.matches(testUrl)); - } - - @Test - public void testGetParamNames() { - assertEquals(2, urlMappingPattern.getParamNames().size()); - assertEquals("param1", urlMappingPattern.getParamNames().get(0)); - assertEquals("param2", urlMappingPattern.getParamNames().get(1)); - } - - @Test - public void testCompile() throws NoSuchFieldException, IllegalAccessException { - // Obtain compiledUrlMappingPattern field with reflection - Field compiledUrlMappingPatternField = UrlMappingPattern.class.getDeclaredField("compiledUrlMappingPattern"); - compiledUrlMappingPatternField.setAccessible(true); - - urlMappingPattern.compile(); - - // Verify that the compiledUrlMappingPattern field is updated - Pattern compiledPattern = (Pattern) compiledUrlMappingPatternField.get(urlMappingPattern); - assertNotNull(compiledPattern); - - // Verify that the mocked pattern is compiled with the expected regex - String expectedRegex = "/test/([%\\w-.\\~!$&'\\(\\)\\*\\+,;=:\\[\\]@]+?)/path/([%\\w-.\\~!$&'\\(\\)\\*\\+,;=:\\[\\]@]+?)(?:\\?.*?)?$"; - Pattern expectedPattern = Pattern.compile(expectedRegex); - assertEquals(expectedPattern.pattern(), compiledPattern.pattern()); - } - - class TestUrlMappingPattern extends UrlMappingPattern { - - private Pattern compiledUrlMappingPattern; - - public TestUrlMappingPattern(String pattern) { - super(pattern); - compiledUrlMappingPattern = mock(Pattern.class); - } - } -} diff --git a/eventmesh-runtime/build.gradle b/eventmesh-runtime/build.gradle index b24cd59a24..c772eca228 100644 --- a/eventmesh-runtime/build.gradle +++ b/eventmesh-runtime/build.gradle @@ -44,6 +44,7 @@ dependencies { implementation project(":eventmesh-security-plugin:eventmesh-security-auth-token") implementation project(":eventmesh-registry-plugin:eventmesh-registry-api") + implementation project(":eventmesh-admin:eventmesh-admin-core") implementation project(":eventmesh-admin:eventmesh-admin-rocketmq") diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java index b08f4e89e4..c981dbd3b8 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java @@ -22,7 +22,7 @@ import org.apache.eventmesh.common.utils.AssertUtils; import org.apache.eventmesh.common.utils.ConfigurationContextUtil; import org.apache.eventmesh.runtime.acl.Acl; -import org.apache.eventmesh.runtime.admin.controller.ClientManageController; +import org.apache.eventmesh.admin.core.controller.ClientManageController; import org.apache.eventmesh.runtime.common.ServiceState; import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.protocol.http.producer.ProducerTopicManager;