This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
commit 13373278044e4a4030f3a18da5f58e32559604c6 Author: liubao <bi...@qq.com> AuthorDate: Sun Oct 8 14:23:37 2023 +0800 [SCB-2008]remove inspector module --- coverage-reports/pom.xml | 6 - dependencies/bom/pom.xml | 8 +- distribution/pom.xml | 6 - inspector/pom.xml | 72 ------ .../inspector/internal/InspectorBootListener.java | 62 ----- .../inspector/internal/InspectorConfig.java | 35 --- .../inspector/internal/InspectorConfiguration.java | 33 --- .../inspector/internal/InspectorImpl.java | 187 -------------- .../internal/model/DynamicPropertyView.java | 59 ----- .../internal/model/PriorityPropertyView.java | 52 ---- .../inspector/internal/swagger/SchemaFormat.java | 32 --- ...rk.boot.autoconfigure.AutoConfiguration.imports | 18 -- inspector/src/main/resources/webroot/index.html | 84 ------- .../src/main/resources/webroot/static/css/main.css | 93 ------- .../webroot/static/dynamicProperties.html | 66 ----- .../webroot/static/images/ServiceComb-logo-3.jpg | Bin 80000 -> 0 bytes .../webroot/static/images/download-all.png | Bin 208 -> 0 bytes .../resources/webroot/static/images/download.png | Bin 178 -> 0 bytes .../src/main/resources/webroot/static/js/main.js | 38 --- .../webroot/static/priorityProperties.html | 89 ------- .../resources/webroot/static/schemas/schemas.css | 37 --- .../resources/webroot/static/schemas/schemas.js | 111 --------- .../main/resources/webroot/static/tree/tree.css | 117 --------- .../src/main/resources/webroot/static/tree/tree.js | 110 --------- .../src/main/resources/webroot/static/welcome.html | 22 -- .../internal/TestInspectorBootListener.java | 81 ------- .../inspector/internal/TestInspectorImpl.java | 269 --------------------- inspector/src/test/resources/microservice.yaml | 23 -- inspector/src/test/resources/schema1.yaml | 61 ----- inspector/src/test/resources/schema2.yaml | 61 ----- pom.xml | 1 - 31 files changed, 1 insertion(+), 1832 deletions(-) diff --git a/coverage-reports/pom.xml b/coverage-reports/pom.xml index 78435f358..8e672de7e 100644 --- a/coverage-reports/pom.xml +++ b/coverage-reports/pom.xml @@ -177,12 +177,6 @@ <artifactId>handler-tracing-zipkin</artifactId> </dependency> - <!-- inspector --> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>inspector</artifactId> - </dependency> - <!-- metrics --> <dependency> <groupId>org.apache.servicecomb</groupId> diff --git a/dependencies/bom/pom.xml b/dependencies/bom/pom.xml index 87ab51385..4268ac285 100644 --- a/dependencies/bom/pom.xml +++ b/dependencies/bom/pom.xml @@ -216,14 +216,8 @@ <artifactId>handler-tracing-zipkin</artifactId> <version>${project.version}</version> </dependency> - <!-- ServiceComb: inspector --> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>inspector</artifactId> - <version>${project.version}</version> - </dependency> - <!-- ServiceComb: metrics --> + <!-- ServiceComb: metrics --> <dependency> <groupId>org.apache.servicecomb</groupId> <artifactId>metrics-core</artifactId> diff --git a/distribution/pom.xml b/distribution/pom.xml index c77e2b01d..947433068 100644 --- a/distribution/pom.xml +++ b/distribution/pom.xml @@ -183,12 +183,6 @@ <artifactId>handler-tracing-zipkin</artifactId> </dependency> - <!-- inspector --> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>inspector</artifactId> - </dependency> - <!-- metrics --> <dependency> <groupId>org.apache.servicecomb</groupId> diff --git a/inspector/pom.xml b/inspector/pom.xml deleted file mode 100644 index 15ebe52f0..000000000 --- a/inspector/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one or more - ~ contributor license agreements. See the NOTICE file distributed with - ~ this work for additional information regarding copyright ownership. - ~ The ASF licenses this file to You under the Apache License, Version 2.0 - ~ (the "License"); you may not use this file except in compliance with - ~ the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <groupId>org.apache.servicecomb</groupId> - <artifactId>java-chassis-parent</artifactId> - <version>3.0.0-SNAPSHOT</version> - <relativePath>../parents/default</relativePath> - </parent> - <modelVersion>4.0.0</modelVersion> - - <artifactId>inspector</artifactId> - <name>Java Chassis::Inspector</name> - - <dependencies> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>transport-rest-vertx</artifactId> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>provider-jaxrs</artifactId> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>registry-local</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>foundation-test-scaffolding</artifactId> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-slf4j-impl</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>transport-rest-servlet</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-inline</artifactId> - <scope>test</scope> - </dependency> - </dependencies> -</project> diff --git a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorBootListener.java b/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorBootListener.java deleted file mode 100644 index c694817f1..000000000 --- a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorBootListener.java +++ /dev/null @@ -1,62 +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.servicecomb.inspector.internal; - -import org.apache.servicecomb.config.MicroserviceProperties; -import org.apache.servicecomb.core.BootListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; - -public class InspectorBootListener implements BootListener { - private static final Logger LOGGER = LoggerFactory.getLogger(InspectorBootListener.class); - - private final InspectorConfig inspectorConfig; - - private MicroserviceProperties microserviceProperties; - - public InspectorBootListener(InspectorConfig inspectorConfig) { - this.inspectorConfig = inspectorConfig; - } - - @Autowired - public void setMicroserviceProperties(MicroserviceProperties microserviceProperties) { - this.microserviceProperties = microserviceProperties; - } - - @Override - public int getOrder() { - return Short.MAX_VALUE; - } - - @Override - public void onAfterTransport(BootEvent event) { - if (!inspectorConfig.isEnabled()) { - LOGGER.info("inspector is not enabled."); - return; - } - LOGGER.info("inspector is enabled."); - - // will not register this schemas to service registry - InspectorImpl inspector = new InspectorImpl() - .setServiceName(microserviceProperties.getName()); - // TODO: inspector get schemas -// .setSchemas(RegistrationManager.INSTANCE.getMicroservice().getSchemaMap()) -// .correctBasePathForOnlineTest(event.getScbEngine()); - event.getScbEngine().getProducerProviderManager().registerSchema("inspector", inspector); - } -} diff --git a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorConfig.java b/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorConfig.java deleted file mode 100644 index 6aa6014b9..000000000 --- a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorConfig.java +++ /dev/null @@ -1,35 +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.servicecomb.inspector.internal; - -import org.apache.servicecomb.config.inject.InjectProperties; -import org.apache.servicecomb.config.inject.InjectProperty; - -@InjectProperties(prefix = "servicecomb.inspector") -public class InspectorConfig { - @InjectProperty(keys = "enabled", defaultValue = "true") - private boolean enabled; - - public boolean isEnabled() { - return enabled; - } - - public InspectorConfig setEnabled(boolean enabled) { - this.enabled = enabled; - return this; - } -} diff --git a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorConfiguration.java b/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorConfiguration.java deleted file mode 100644 index 47ac953dc..000000000 --- a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorConfiguration.java +++ /dev/null @@ -1,33 +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.servicecomb.inspector.internal; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class InspectorConfiguration { - @Bean - public InspectorBootListener inspectorBootListener(InspectorConfig inspectorConfig) { - return new InspectorBootListener(inspectorConfig); - } - - @Bean - public InspectorConfig inspectorConfig() { - return new InspectorConfig(); - } -} diff --git a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorImpl.java b/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorImpl.java deleted file mode 100644 index cfe7de0a5..000000000 --- a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorImpl.java +++ /dev/null @@ -1,187 +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.servicecomb.inspector.internal; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.nio.charset.StandardCharsets; -import java.util.Collection; -import java.util.Map; -import java.util.Map.Entry; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -import org.apache.commons.lang3.StringUtils; -import org.apache.servicecomb.common.rest.resource.ClassPathStaticResourceHandler; -import org.apache.servicecomb.common.rest.resource.StaticResourceHandler; -import org.apache.servicecomb.core.CoreConst; -import org.apache.servicecomb.core.SCBEngine; -import org.apache.servicecomb.core.Transport; -import org.apache.servicecomb.foundation.common.part.InputStreamPart; -import org.apache.servicecomb.foundation.common.utils.ClassLoaderScopeContext; -import org.apache.servicecomb.inspector.internal.swagger.SchemaFormat; -import org.apache.servicecomb.registry.definition.DefinitionConst; -import org.apache.servicecomb.swagger.SwaggerUtils; -import org.apache.servicecomb.swagger.invocation.Response; -import org.apache.servicecomb.swagger.invocation.exception.InvocationException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.annotations.VisibleForTesting; - -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.models.OpenAPI; -import jakarta.servlet.http.Part; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; -import jakarta.ws.rs.QueryParam; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; -import jakarta.ws.rs.core.Response.Status; - -@Path("/inspector") -public class InspectorImpl { - private static final Logger LOGGER = LoggerFactory.getLogger(InspectorImpl.class); - - private final StaticResourceHandler resourceHandler = new ClassPathStaticResourceHandler(); - - private Map<String, String> schemas; - - private String serviceName; - - @VisibleForTesting - public Map<String, String> getSchemas() { - return schemas; - } - - public InspectorImpl setServiceName(String serviceName) { - this.serviceName = serviceName; - return this; - } - - public InspectorImpl setSchemas(Map<String, String> schemas) { - this.schemas = schemas; - return this; - } - - // when work in servlet mode, should concat url prefix - // otherwise swagger ide can not run online test - // - // ServiceComb consumer has not this problem - // ServiceComb consumer not care for producer deploy with or without servlet - public InspectorImpl correctBasePathForOnlineTest(SCBEngine scbEngine) { - Transport restTransport = scbEngine.getTransportManager().findTransport(CoreConst.RESTFUL); - if (restTransport == null || - !restTransport.getClass().getName() - .equals("org.apache.servicecomb.transport.rest.servlet.ServletRestTransport")) { - return this; - } - - String urlPrefix = ClassLoaderScopeContext.getClassLoaderScopeProperty(DefinitionConst.URL_PREFIX); - if (StringUtils.isEmpty(urlPrefix)) { - return this; - } - - for (Entry<String, String> entry : schemas.entrySet()) { - OpenAPI swagger = SwaggerUtils.parseSwagger(entry.getValue()); - if (SwaggerUtils.getBasePath(swagger).startsWith(urlPrefix)) { - continue; - } - - SwaggerUtils.setBasePath(swagger, urlPrefix + SwaggerUtils.getBasePath(swagger)); - - entry.setValue(SwaggerUtils.swaggerToString(swagger)); - } - return this; - } - - @Path("/schemas") - @GET - public Collection<String> getSchemaIds() { - return schemas.keySet(); - } - - @Path("/download/schemas") - @GET - @ApiResponse(responseCode = "200", description = "", content = - @Content(schema = @Schema(type = "string", format = "binary"))) - public Response downloadSchemas(@QueryParam("format") SchemaFormat format) { - if (format == null) { - format = SchemaFormat.SWAGGER; - } - - // normally, schema will not be too big, just save them in memory temporarily - ByteArrayOutputStream os = new ByteArrayOutputStream(); - try (ZipOutputStream zos = new ZipOutputStream(os)) { - for (Entry<String, String> entry : schemas.entrySet()) { - // begin writing a new ZIP entry, positions the stream to the start of the entry data - zos.putNextEntry(new ZipEntry(entry.getKey() + format.getSuffix())); - - String content = entry.getValue(); - zos.write(content.getBytes(StandardCharsets.UTF_8)); - zos.closeEntry(); - } - } catch (Throwable e) { - String msg = "failed to create schemas zip file, format=" + format + "."; - LOGGER.error(msg, e); - return Response.failResp(new InvocationException(Status.INTERNAL_SERVER_ERROR, msg)); - } - - Part part = new InputStreamPart(null, new ByteArrayInputStream(os.toByteArray())) - .setSubmittedFileName(serviceName + format.getSuffix() + ".zip"); - return Response.ok(part); - } - - @Path("/schemas/{schemaId}") - @GET - @ApiResponse(responseCode = "200", description = "", content = - @Content(schema = @Schema(type = "string", format = "binary"))) - public Response getSchemaContentById(@PathParam("schemaId") String schemaId, - @QueryParam("format") SchemaFormat format, @QueryParam("download") boolean download) { - String swaggerContent = schemas.get(schemaId); - if (swaggerContent == null) { - return Response.failResp(new InvocationException(Status.NOT_FOUND, Status.NOT_FOUND.getReasonPhrase())); - } - - if (format == null) { - format = SchemaFormat.SWAGGER; - } - - byte[] bytes = swaggerContent.getBytes(StandardCharsets.UTF_8); - - Part part = new InputStreamPart(null, new ByteArrayInputStream(bytes)) - .setSubmittedFileName(schemaId + format.getSuffix()); - - Response response = Response.ok(part); - if (!download) { - response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "inline"); - } - response.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML); - return response; - } - - @Path("/{path : .+}") - @GET - @ApiResponse(responseCode = "200", description = "", content = - @Content(schema = @Schema(type = "string", format = "binary"))) - public Response getStaticResource(@PathParam("path") String path) { - return resourceHandler.handle(path); - } -} diff --git a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/model/DynamicPropertyView.java b/inspector/src/main/java/org/apache/servicecomb/inspector/internal/model/DynamicPropertyView.java deleted file mode 100644 index bf7c68fc7..000000000 --- a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/model/DynamicPropertyView.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.servicecomb.inspector.internal.model; - -public class DynamicPropertyView { - private String key; - - private String value; - - private String changedTime = ""; - - private int callbackCount; - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public String getChangedTime() { - return changedTime; - } - - public void setChangedTime(String changedTime) { - this.changedTime = changedTime; - } - - public int getCallbackCount() { - return callbackCount; - } - - public void setCallbackCount(int callbackCount) { - this.callbackCount = callbackCount; - } -} diff --git a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/model/PriorityPropertyView.java b/inspector/src/main/java/org/apache/servicecomb/inspector/internal/model/PriorityPropertyView.java deleted file mode 100644 index d1524946d..000000000 --- a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/model/PriorityPropertyView.java +++ /dev/null @@ -1,52 +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.servicecomb.inspector.internal.model; - -import java.util.List; - -public class PriorityPropertyView { - private List<DynamicPropertyView> dynamicProperties; - - private String defaultValue; - - private String value; - - public List<DynamicPropertyView> getDynamicProperties() { - return dynamicProperties; - } - - public void setDynamicProperties( - List<DynamicPropertyView> dynamicProperties) { - this.dynamicProperties = dynamicProperties; - } - - public String getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } -} diff --git a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/swagger/SchemaFormat.java b/inspector/src/main/java/org/apache/servicecomb/inspector/internal/swagger/SchemaFormat.java deleted file mode 100644 index 099350c3d..000000000 --- a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/swagger/SchemaFormat.java +++ /dev/null @@ -1,32 +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.servicecomb.inspector.internal.swagger; - -public enum SchemaFormat { - SWAGGER(".yaml"), - HTML(".html"); - - private final String suffix; - - SchemaFormat(String suffix) { - this.suffix = suffix; - } - - public String getSuffix() { - return suffix; - } -} diff --git a/inspector/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/inspector/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index c98a4535b..000000000 --- a/inspector/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,18 +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. -## --------------------------------------------------------------------------- - -org.apache.servicecomb.inspector.internal.InspectorConfiguration diff --git a/inspector/src/main/resources/webroot/index.html b/inspector/src/main/resources/webroot/index.html deleted file mode 100644 index 29b3ccb93..000000000 --- a/inspector/src/main/resources/webroot/index.html +++ /dev/null @@ -1,84 +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. - --> - -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8"> - <title>ServiceComb inspector</title> - <link rel="stylesheet" href="static/css/main.css"> - <link rel="stylesheet" href="static/schemas/schemas.css"> - <link rel="stylesheet" href="static/tree/tree.css"> - <link rel="icon" type="image/png" href="static/images/ServiceComb-logo-3.jpg"/> - - <link rel="preload" href="static/js/main.js" as="script"> - <link rel="preload" href="static/schemas/schemas.js" as="script"> - - <script src="static/js/main.js"></script> - <script src="static/tree/tree.js"></script> - <script src="static/schemas/schemas.js"></script> -</head> -<body> -<div class="left"> - <img id="scbLogo" src="static/images/ServiceComb-logo-3.jpg"/> - <tree id="mainTree"> - <tree-node id="configs" no-action expanded="true"> - <tree-face> - <tree-node-open-close></tree-node-open-close> - <tree-label>configs</tree-label> - </tree-face> - <tree-children> - <tree-node id="dynamicProperties"> - <tree-face> - <tree-label onclick="frame.location = 'static/dynamicProperties.html'">dynamic properties</tree-label> - </tree-face> - </tree-node> - <tree-node id="priorityProperties"> - <tree-face> - <tree-label onclick="frame.location = 'static/priorityProperties.html'">priority properties</tree-label> - </tree-face> - </tree-node> - </tree-children> - </tree-node> - <tree-node id="schemas" no-action expanded="true"> - <tree-face> - <tree-node-open-close></tree-node-open-close> - <tree-label>schemas</tree-label> - <select id="schema-format"> - <option value="SWAGGER">swagger</option> - <option value="HTML">html</option> - </select> - <div class="download download-all" onclick="clickDownloadAllSchemas(event)"></div> - </tree-face> - </tree-node> - </tree> -</div> -<div class="content"> - <iframe src="static/welcome.html" allowfullscreen scrolling="no"></iframe> -</div> - -<script> - var mainTree = new Tree("mainTree") - var frame = null; - - window.onload = function () { - frame = window.frames[0]; - initSchemas(); - }; -</script> -</body> -</html> \ No newline at end of file diff --git a/inspector/src/main/resources/webroot/static/css/main.css b/inspector/src/main/resources/webroot/static/css/main.css deleted file mode 100644 index 17cd2f6e1..000000000 --- a/inspector/src/main/resources/webroot/static/css/main.css +++ /dev/null @@ -1,93 +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. - */ - -* { - box-sizing: border-box; -} - -html, -body { - width: 100%; - height: 100%; - margin: 0px; - display: flex; -} - -.left { - flex-direction: column; - flex-shrink: 0; - width: 300px; - height: 100%; - overflow-y: scroll; -} - -.content { - overflow: hidden; - position: relative; - height: 100%; - width: 100%; -} - -.content iframe { - border: 0; - height: 100%; - left: 0; - position: absolute; - top: 0; - width: 100%; -} - -#scbLogo { - margin: auto; - display: block; - width: 50%; -} - -.table-container { - width: 100%; - margin: 10px; - overflow-y: scroll; -} - -.table { - border-spacing: 0px; - width: 100%; - word-wrap: break-word; - word-break: break-all; -} - -.table.left-head th { - text-align: left; - white-space: nowrap; -} - -.table tr:nth-of-type(even) { - background: #f8f8f7 -} - -.table.fix-head thead th { - position: sticky; - position: -webkit-sticky; - top: 0; - z-index: 999; - background: #f7f8f7; -} - -.table th, .table td { - border: 1px solid #dedede; - padding: 8px; -} \ No newline at end of file diff --git a/inspector/src/main/resources/webroot/static/dynamicProperties.html b/inspector/src/main/resources/webroot/static/dynamicProperties.html deleted file mode 100644 index 04e609044..000000000 --- a/inspector/src/main/resources/webroot/static/dynamicProperties.html +++ /dev/null @@ -1,66 +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. - --> - -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8"> - - <link rel="stylesheet" href="css/main.css"> - - <style> - .table td:nth-last-child(-n+2) { - white-space: nowrap; - } - </style> - <script src="js/main.js"></script> -</head> -<body> - -<div class="table-container"> - <table class="table fix-head left-head" id="configs"> - <thead> - <tr> - <th>index</th> - <th>key</th> - <th>value</th> - <th>changed time</th> - <th>callback count</th> - </tr> - </thead> - <tbody></tbody> - </table> -</div> - -<script> - ajaxJsonGet("../dynamicProperties", function (configs) { - var html = ""; - for (var idx in configs) { - var config = configs[idx]; - html += "<tr>" + - "<td>" + idx + "</td>" + - "<td>" + config.key + "</td>" + - "<td>" + config.value + "</td>" + - "<td>" + config.changedTime + "</td>" + - "<td>" + config.callbackCount + "</td>" + - "</tr>"; - } - document.querySelector("#configs tbody").innerHTML = html; - }) -</script> -</body> -</html> \ No newline at end of file diff --git a/inspector/src/main/resources/webroot/static/images/ServiceComb-logo-3.jpg b/inspector/src/main/resources/webroot/static/images/ServiceComb-logo-3.jpg deleted file mode 100644 index b2cb70678..000000000 Binary files a/inspector/src/main/resources/webroot/static/images/ServiceComb-logo-3.jpg and /dev/null differ diff --git a/inspector/src/main/resources/webroot/static/images/download-all.png b/inspector/src/main/resources/webroot/static/images/download-all.png deleted file mode 100644 index 97637b3c5..000000000 Binary files a/inspector/src/main/resources/webroot/static/images/download-all.png and /dev/null differ diff --git a/inspector/src/main/resources/webroot/static/images/download.png b/inspector/src/main/resources/webroot/static/images/download.png deleted file mode 100644 index b898f9d8a..000000000 Binary files a/inspector/src/main/resources/webroot/static/images/download.png and /dev/null differ diff --git a/inspector/src/main/resources/webroot/static/js/main.js b/inspector/src/main/resources/webroot/static/js/main.js deleted file mode 100644 index e68ff58cf..000000000 --- a/inspector/src/main/resources/webroot/static/js/main.js +++ /dev/null @@ -1,38 +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. - */ - -function ajaxGet(url, succCallback) { - var xmlhttp = new XMLHttpRequest(); - xmlhttp.onreadystatechange = function () { - if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { - succCallback(xmlhttp.responseText); - } - } - xmlhttp.open("GET", url, true); - xmlhttp.send(); -} - -function ajaxJsonGet(url, succCallback) { - ajaxGet(url, function (text) { - succCallback(JSON.parse(text)) - }); -} - -function getBlobURL(code, type) { - var blob = new Blob([code], {type: type}) - return URL.createObjectURL(blob) -} \ No newline at end of file diff --git a/inspector/src/main/resources/webroot/static/priorityProperties.html b/inspector/src/main/resources/webroot/static/priorityProperties.html deleted file mode 100644 index e816fcd3e..000000000 --- a/inspector/src/main/resources/webroot/static/priorityProperties.html +++ /dev/null @@ -1,89 +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. - --> - -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8"> - - <link rel="stylesheet" href="css/main.css"> - - <style> - .table td { - min-width: 100px; - } - - .table td:nth-last-child(-n+2) { - white-space: nowrap; - } - </style> - <script src="js/main.js"></script> -</head> -<body> - -<div class="table-container"> - <table class="table fix-head left-head" id="configs"> - <thead> - <tr> - <th>index</th> - <th>value</th> - <th>default value</th> - <th>key</th> - <th>value</th> - <th>changed time</th> - <th>callback count</th> - </tr> - </thead> - <tbody></tbody> - </table> -</div> - -<script> - ajaxJsonGet("../priorityProperties", function (configs) { - var html = ""; - for (var idx in configs) { - var config = configs[idx]; - var dynamicProperties = config.dynamicProperties; - - var rowspan = ">"; - if (dynamicProperties.length != 1) { - rowspan = " rowspan='" + dynamicProperties.length + "'>"; - } - html += "<tr>" + - "<td" + rowspan + idx + "</td>" + - "<td" + rowspan + config.value + "</td>" + - "<td" + rowspan + config.defaultValue + "</td>" + - "<td>" + dynamicProperties[0].key + "</td>" + - "<td>" + dynamicProperties[0].value + "</td>" + - "<td>" + dynamicProperties[0].changedTime + "</td>" + - "<td>" + dynamicProperties[0].callbackCount + "</td>" + - "</tr>"; - - for (var propIdx = 1; propIdx < dynamicProperties.length; propIdx++) { - html += "<tr>" + - "<td>" + dynamicProperties[propIdx].key + "</td>" + - "<td>" + dynamicProperties[propIdx].value + "</td>" + - "<td>" + dynamicProperties[propIdx].changedTime + "</td>" + - "<td>" + dynamicProperties[propIdx].callbackCount + "</td>" + - "</tr>"; - } - } - document.querySelector("#configs tbody").innerHTML = html; - }) -</script> -</body> -</html> \ No newline at end of file diff --git a/inspector/src/main/resources/webroot/static/schemas/schemas.css b/inspector/src/main/resources/webroot/static/schemas/schemas.css deleted file mode 100644 index b8905caf0..000000000 --- a/inspector/src/main/resources/webroot/static/schemas/schemas.css +++ /dev/null @@ -1,37 +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. - */ - -#schema-format { - margin-right: 4px; - width: 80px; - flex-shrink: 0; -} - -#schemas .download { - background-image: url(../images/download.png); - background-size: 100% 100%; - width: 15px; - height: 18px; - flex-shrink: 0; - margin-right: 3px; - align-self: center; - cursor: pointer; -} - -#schemas .download.download-all { - background-image: url(../images/download-all.png); -} \ No newline at end of file diff --git a/inspector/src/main/resources/webroot/static/schemas/schemas.js b/inspector/src/main/resources/webroot/static/schemas/schemas.js deleted file mode 100644 index 788428cb0..000000000 --- a/inspector/src/main/resources/webroot/static/schemas/schemas.js +++ /dev/null @@ -1,111 +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. - */ - -function initSchemas() { - var eleFormat = document.getElementById("schema-format"); - eleFormat.onchange = function () { - localStorage.setItem("schemaFormatIdx", eleFormat.selectedIndex); - if (mainTree.config.activeNodeId != null && mainTree.config.activeNodeId.startsWith("schemas://")) { - mainTree.clickActiveTreeNode(); - } - }; - var formatIdx = localStorage.getItem("schemaFormatIdx"); - if (formatIdx != null) { - eleFormat.selectedIndex = formatIdx; - } - - ajaxJsonGet("schemas", initSchemasTree); -} - -function initSchemasTree(schemas) { - schemas = schemas.sort(); - var eleSchemas = document.getElementById("schemas"); - var childrenContent = "<tree-children>"; - for (var idx in schemas) { - childrenContent += '<tree-node id="schemas://' + schemas[idx] + '">' + - ' <tree-face>' + - ' <tree-label onclick="clickShowSchema(event)">' + schemas[idx] + '</tree-label>' + - ' <div class="download" onclick="clickDownloadSchema(event)"></div>' + - ' </tree-face>' + - '</tree-node>'; - } - childrenContent += '</tree-children>'; - eleSchemas.insertAdjacentHTML("beforeend", childrenContent); - - mainTree.init(); -} - -function fetchAndshowSchemaAsSwagger(url) { - ajaxGet(url, function (schema) { - frame.editor.specActions.updateSpec(schema); - }); -} - -function showSchemaAsSwagger(url) { - if (frame.SwaggerEditorBundle != null) { - // reuse swagger editor - fetchAndshowSchemaAsSwagger(url); - return; - } - - ajaxGet(url, function (schema) { - localStorage.setItem("swagger-editor-content", schema); - }); - // this cdn return html as text/plain, so we must let iframe load it as html - ajaxGet("https://cdn.jsdelivr.net/npm/swagger-editor-dist@3.6.24/index.html", - function (html) { - html = html.replace('<style>', - '<base href="https://cdn.jsdelivr.net/npm/swagger-editor-dist@3.6.24/">\n' - + ' <style>\n' - + ' .swagger-ui .info .title {' - + ' word-break: break-all;\n' - + ' }\n'); - frame.location = getBlobURL(html, "text/html"); - }); -} - -function clickShowSchema(event) { - var schemaId = event.target.innerText; - localStorage.setItem("schemaId", schemaId); - - var eleFormat = document.getElementById("schema-format"); - var format = eleFormat.options[eleFormat.selectedIndex].value; - var url = "schemas/" + schemaId + "?download=false&format=" + format; - if (format == "SWAGGER") { - showSchemaAsSwagger(url); - return; - } - - if (format == "HTML") { - frame.location = url; - } -} - -function clickDownloadSchema(event) { - var schemaId = event.target.previousElementSibling.innerText; - var eleFormat = document.getElementById("schema-format"); - var format = eleFormat.options[eleFormat.selectedIndex].value; - - window.location = "schemas/" + schemaId + "?download=true&format=" + format; -} - -function clickDownloadAllSchemas(event) { - var eleFormat = document.getElementById("schema-format"); - var format = eleFormat.options[eleFormat.selectedIndex].value; - - window.location = "download/schemas?format=" + format; -} \ No newline at end of file diff --git a/inspector/src/main/resources/webroot/static/tree/tree.css b/inspector/src/main/resources/webroot/static/tree/tree.css deleted file mode 100644 index 6635a2144..000000000 --- a/inspector/src/main/resources/webroot/static/tree/tree.css +++ /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. - */ - -tree { - display: block; - font-family: serif; -} - -tree-node { - display: block; - border-left: 1px solid #777; - position: relative; -} - -tree > tree-node { - border-left: 0px; -} - -tree-node:last-child:after { - border-left: 1px solid white; - display: block; - height: 50%; - position: absolute; - left: -1px; - top: 50%; - content: ''; -} - -tree-node:before { - position: absolute; - display: block; - top: 50%; - height: 1px; - width: 10px; - background-color: #777; - content: ''; -} - -tree > tree-node:before { - display: none; -} - -tree-face { - display: flex; - justify-content: space-between; - padding: 2px 0 2px 4px; -} - -tree-children tree-face { - padding: 2px 0 2px 8px; -} - -tree-node-open-close { - display: block; - flex-shrink: 0; - align-self: center; - - background: gray; - color: white; - width: 16px; - height: 16px; - border-radius: 16px; - line-height: 16px; - text-align: center; -} - -tree-node-open-close:before { - content: "+"; -} - -tree-node[expanded=true] > tree-face > tree-node-open-close:before { - content: ""; - display: block; - width: 8px; - height: 1px; - margin: 8px 0 0 4px; - background-color: white; -} - -tree-node[expanded=false] > tree-children { - display: none; -} - -tree-label { - display: block; - width: 100%; - margin-left: 4px; - cursor: pointer; - word-break: break-all; -} - -tree-label:hover { - color: #888; -} - -tree-node.active > tree-face > tree-label { - background-color: #ccc; -} - -tree-children { - margin-left: 10px; - display: block; -} diff --git a/inspector/src/main/resources/webroot/static/tree/tree.js b/inspector/src/main/resources/webroot/static/tree/tree.js deleted file mode 100644 index 2fda4cc8b..000000000 --- a/inspector/src/main/resources/webroot/static/tree/tree.js +++ /dev/null @@ -1,110 +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. - */ -function Tree(id) { - var tree = this; - this.eleTree = document.getElementById(id); - this.eleTree.onclick = function (event) { - tree.onTreeClicked(event); - }; - this.activeTreeNode = null; - this.configId = id + "-config"; - - var defaultConfig = { - activeNodeId: null, - expanded: {} - }; - this.config = Object.assign(defaultConfig, - JSON.parse(localStorage.getItem(this.configId))); -} - -Tree.prototype.init = function () { - // restore expanded - for (var id in this.config.expanded) { - var ele = document.getElementById(id); - if (ele != null) { - ele.setAttribute("expanded", this.config.expanded[id]); - } - } - - // click active node - this.clickActiveTreeNode(); -} - -Tree.prototype.clickActiveTreeNode = function () { - if (this.config.activeNodeId != null) { - var treeNode = document.getElementById(this.config.activeNodeId); - if (treeNode != null) { - treeNode.querySelector(":scope > tree-face > tree-label").click(); - return; - } - } - - var treeLabel = this.eleTree.querySelector("tree-node:not([no-action]) > tree-face > tree-label"); - if (treeLabel != null) { - treeLabel.click(); - } -} - -Tree.prototype.saveConfig = function () { - localStorage.setItem(this.configId, JSON.stringify(this.config)); -} - -Tree.prototype.onTreeClicked = function (event) { - if (event.target.localName == "tree-label") { - this.onTreeLabelClicked(event); - return; - } - - if (event.target.localName == "tree-node-open-close") { - this.onTreeNodeOpenCloseClicked(event); - return; - } -} - -Tree.prototype.onTreeNodeOpenCloseClicked = function (event) { - var treeNode = event.target.parentElement.parentElement; - var expanded = treeNode.getAttribute("expanded") == "true"; - expanded = !expanded; - treeNode.setAttribute("expanded", expanded); - - var id = treeNode.getAttribute("id"); - if (id != null) { - this.config.expanded[id] = expanded; - this.saveConfig(); - } -} - -Tree.prototype.onTreeLabelClicked = function (event) { - var treeNode = event.target.parentElement.parentElement; - if (treeNode.hasAttribute("no-action")) { - return; - } - - // switch active status - if (this.activeTreeNode != null) { - this.activeTreeNode.classList.remove("active"); - } - this.activeTreeNode = treeNode; - this.activeTreeNode.classList.add("active"); - - // save status - var id = this.activeTreeNode.getAttribute("id"); - if (id != null) { - this.config.activeNodeId = id; - this.saveConfig(); - } -} diff --git a/inspector/src/main/resources/webroot/static/welcome.html b/inspector/src/main/resources/webroot/static/welcome.html deleted file mode 100644 index 9e364d9bd..000000000 --- a/inspector/src/main/resources/webroot/static/welcome.html +++ /dev/null @@ -1,22 +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. - --> -<!DOCTYPE html> -<html lang="en"> -<body> -welcome -</body> -</html> \ No newline at end of file diff --git a/inspector/src/test/java/org/apache/servicecomb/inspector/internal/TestInspectorBootListener.java b/inspector/src/test/java/org/apache/servicecomb/inspector/internal/TestInspectorBootListener.java deleted file mode 100644 index 9203082dd..000000000 --- a/inspector/src/test/java/org/apache/servicecomb/inspector/internal/TestInspectorBootListener.java +++ /dev/null @@ -1,81 +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.servicecomb.inspector.internal; - -import org.apache.servicecomb.core.BootListener.BootEvent; -import org.apache.servicecomb.core.BootListener.EventType; -import org.apache.servicecomb.core.SCBEngine; -import org.apache.servicecomb.core.bootstrap.SCBBootstrap; -import org.apache.servicecomb.core.definition.MicroserviceMeta; -import org.apache.servicecomb.foundation.common.LegacyPropertyFactory; -import org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.springframework.core.env.Environment; - -import io.vertx.core.file.impl.FileResolverImpl; - -public class TestInspectorBootListener { - Environment environment = Mockito.mock(Environment.class); - - @BeforeEach - public void setUp() { - Mockito.when(environment.getProperty("servicecomb.transport.eventloop.size", int.class, -1)) - .thenReturn(-1); - Mockito.when(environment.getProperty(FileResolverImpl.DISABLE_CP_RESOLVING_PROP_NAME, boolean.class, true)) - .thenReturn(true); - LegacyPropertyFactory.setEnvironment(environment); - } - - @Test - public void getOrder() { - Assertions.assertEquals(Short.MAX_VALUE, new InspectorBootListener(null).getOrder()); - } - - @Test - public void filterEvent() { - BootEvent event = new BootEvent(); - InspectorBootListener listener = new InspectorBootListener(new InspectorConfig()); - - try (LogCollector logCollector = new LogCollector()) { - for (EventType eventType : EventType.values()) { - if (!EventType.AFTER_TRANSPORT.equals(eventType)) { - event.setEventType(eventType); - listener.onBootEvent(event); - } - } - - Assertions.assertTrue(logCollector.getEvents().isEmpty()); - } - } - - @Test - public void disabled() { - SCBEngine scbEngine = SCBBootstrap.createSCBEngineForTest(); - scbEngine.setProducerMicroserviceMeta(new MicroserviceMeta(scbEngine, - "app", "ms", false)); - - InspectorConfig inspectorConfig = new InspectorConfig() - .setEnabled(false); - new InspectorBootListener(inspectorConfig) - .onAfterTransport(new BootEvent(scbEngine, EventType.AFTER_TRANSPORT)); - - Assertions.assertNull(scbEngine.getProducerMicroserviceMeta().findSchemaMeta("inspector")); - } -} diff --git a/inspector/src/test/java/org/apache/servicecomb/inspector/internal/TestInspectorImpl.java b/inspector/src/test/java/org/apache/servicecomb/inspector/internal/TestInspectorImpl.java deleted file mode 100644 index b99d6a58d..000000000 --- a/inspector/src/test/java/org/apache/servicecomb/inspector/internal/TestInspectorImpl.java +++ /dev/null @@ -1,269 +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.servicecomb.inspector.internal; - -import static org.apache.servicecomb.core.CoreConst.RESTFUL; -import static org.apache.servicecomb.core.SCBEngine.CFG_KEY_TURN_DOWN_STATUS_WAIT_SEC; -import static org.apache.servicecomb.core.SCBEngine.DEFAULT_TURN_DOWN_STATUS_WAIT_SEC; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.servicecomb.core.SCBEngine; -import org.apache.servicecomb.core.Transport; -import org.apache.servicecomb.core.bootstrap.SCBBootstrap; -import org.apache.servicecomb.foundation.common.LegacyPropertyFactory; -import org.apache.servicecomb.foundation.common.utils.ClassLoaderScopeContext; -import org.apache.servicecomb.foundation.test.scaffolding.exception.RuntimeExceptionWithoutStackTrace; -import org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector; -import org.apache.servicecomb.inspector.internal.swagger.SchemaFormat; -import org.apache.servicecomb.registry.definition.DefinitionConst; -import org.apache.servicecomb.swagger.invocation.Response; -import org.apache.servicecomb.swagger.invocation.exception.CommonExceptionData; -import org.apache.servicecomb.swagger.invocation.exception.InvocationException; -import org.apache.servicecomb.transport.rest.servlet.ServletRestTransport; -import org.hamcrest.MatcherAssert; -import org.hamcrest.Matchers; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.EnabledForJreRange; -import org.junit.jupiter.api.condition.JRE; -import org.mockito.Mockito; -import org.springframework.core.env.Environment; - -import io.vertx.core.file.impl.FileResolverImpl; -import jakarta.servlet.http.Part; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; -import jakarta.ws.rs.core.Response.Status; - -public class TestInspectorImpl { - static Map<String, String> schemas = new LinkedHashMap<>(); - - static InspectorImpl inspector; - - @BeforeAll - public static void setup() throws IOException { - schemas.put("schema1", IOUtils - .toString(TestInspectorImpl.class.getClassLoader().getResource("schema1.yaml"), StandardCharsets.UTF_8)); - schemas.put("schema2", IOUtils - .toString(TestInspectorImpl.class.getClassLoader().getResource("schema2.yaml"), StandardCharsets.UTF_8)); - } - - Environment environment = Mockito.mock(Environment.class); - - @BeforeEach - public void setUp() { - inspector = initInspector(null); - LegacyPropertyFactory.setEnvironment(environment); - } - - private InspectorImpl initInspector(String urlPrefix) { - SCBEngine scbEngine = SCBBootstrap.createSCBEngineForTest(); - scbEngine.setEnvironment(environment); - Mockito.when(environment.getProperty(CFG_KEY_TURN_DOWN_STATUS_WAIT_SEC, - long.class, DEFAULT_TURN_DOWN_STATUS_WAIT_SEC)).thenReturn(DEFAULT_TURN_DOWN_STATUS_WAIT_SEC); - scbEngine.getTransportManager().clearTransportBeforeInit(); - - if (StringUtils.isNotEmpty(urlPrefix)) { - Map<String, Transport> transportMap = scbEngine.getTransportManager().getTransportMap(); - ServletRestTransport servletRestTransport = new ServletRestTransport(); - servletRestTransport.setEnvironment(environment); - transportMap.put(RESTFUL, servletRestTransport); - ClassLoaderScopeContext.setClassLoaderScopeProperty(DefinitionConst.URL_PREFIX, urlPrefix); - } - - scbEngine.run(); - InspectorImpl inspector = new InspectorImpl() - .setSchemas(schemas); - inspector.correctBasePathForOnlineTest(scbEngine); - return inspector; - } - - @AfterAll - public static void teardown() { - SCBEngine.getInstance().destroy(); - ClassLoaderScopeContext.clearClassLoaderScopeProperty(); - } - - private Map<String, String> unzip(InputStream is) throws IOException { - Map<String, String> result = new LinkedHashMap<>(); - ZipInputStream zis = new ZipInputStream(is); - for (; ; ) { - ZipEntry zipEntry = zis.getNextEntry(); - if (zipEntry == null) { - zis.close(); - return result; - } - - result.put(zipEntry.getName(), IOUtils.toString(zis, StandardCharsets.UTF_8)); - } - } - - @Test - public void getSchemaIds() { - MatcherAssert.assertThat(inspector.getSchemaIds(), Matchers.contains("schema1", "schema2")); - } - - @Test - public void downloadSchemas_default_to_swagger() throws IOException { - testDownloadSchemasSwagger(null); - } - - @Test - public void downloadSchemas_swagger() throws IOException { - testDownloadSchemasSwagger(SchemaFormat.SWAGGER); - } - - private void testDownloadSchemasSwagger(SchemaFormat format) throws IOException { - inspector.setServiceName("ms"); - - Response response = inspector.downloadSchemas(format); - Part part = response.getResult(); - Assertions.assertEquals("ms.yaml.zip", part.getSubmittedFileName()); - - try (InputStream is = part.getInputStream()) { - Map<String, String> unziped = unzip(is); - - Assertions.assertEquals(schemas.size(), unziped.size()); - Assertions.assertEquals(schemas.get("schema1"), unziped.get("schema1.yaml")); - Assertions.assertEquals(schemas.get("schema2"), unziped.get("schema2.yaml")); - } - } - - @Test - @EnabledForJreRange(min = JRE.JAVA_9) - public void downloadSchemas_failed() { - SchemaFormat format = Mockito.spy(SchemaFormat.SWAGGER); - Mockito.doThrow(new RuntimeExceptionWithoutStackTrace("zip failed.")).when(format).getSuffix(); - - try (LogCollector logCollector = new LogCollector()) { - Response response = inspector.downloadSchemas(format); - - Assertions.assertEquals("failed to create schemas zip file, format=SWAGGER.", - logCollector.getLastEvents().getMessage().getFormattedMessage()); - - InvocationException invocationException = response.getResult(); - Assertions.assertEquals(Status.INTERNAL_SERVER_ERROR, invocationException.getStatus()); - Assertions.assertEquals("failed to create schemas zip file, format=SWAGGER.", - ((CommonExceptionData) invocationException.getErrorData()).getMessage()); - Assertions.assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode()); - Assertions.assertEquals(Status.INTERNAL_SERVER_ERROR.getReasonPhrase(), response.getReasonPhrase()); - } - } - - @Test - public void getSchemaContentById_notExist() { - Response response = inspector.getSchemaContentById("notExist", null, false); - - InvocationException invocationException = response.getResult(); - Assertions.assertEquals(Status.NOT_FOUND, invocationException.getStatus()); - Assertions.assertEquals(Status.NOT_FOUND.getReasonPhrase(), - ((CommonExceptionData) invocationException.getErrorData()).getMessage()); - Assertions.assertEquals(404, response.getStatusCode()); - Assertions.assertEquals("Not Found", response.getReasonPhrase()); - } - - @Test - public void getSchemaContentById_view_swagger() throws IOException { - testViewSwaggerById("schema1", null); - testViewSwaggerById("schema1", SchemaFormat.SWAGGER); - testViewSwaggerById("schema2", null); - testViewSwaggerById("schema2", SchemaFormat.SWAGGER); - } - - private void testViewSwaggerById(String schemaId, SchemaFormat format) throws IOException { - Response response = inspector.getSchemaContentById(schemaId, format, false); - - Part part = response.getResult(); - Assertions.assertEquals(schemaId + ".yaml", part.getSubmittedFileName()); - Assertions.assertEquals("inline", response.getHeader(HttpHeaders.CONTENT_DISPOSITION)); - Assertions.assertEquals(MediaType.TEXT_HTML, response.getHeader(HttpHeaders.CONTENT_TYPE)); - - try (InputStream is = part.getInputStream()) { - Assertions.assertEquals(schemas.get(schemaId), IOUtils.toString(is, StandardCharsets.UTF_8)); - } - } - - @Test - public void getSchemaContentById_download_swagger() throws IOException { - testDownloadSwaggerById("schema1", null); - testDownloadSwaggerById("schema1", SchemaFormat.SWAGGER); - testDownloadSwaggerById("schema2", null); - testDownloadSwaggerById("schema2", SchemaFormat.SWAGGER); - } - - private void testDownloadSwaggerById(String schemaId, SchemaFormat format) throws IOException { - Response response = inspector.getSchemaContentById(schemaId, format, true); - - Part part = response.getResult(); - Assertions.assertEquals(schemaId + ".yaml", part.getSubmittedFileName()); - Assertions.assertNull(response.getHeader(HttpHeaders.CONTENT_DISPOSITION)); - Assertions.assertEquals(MediaType.TEXT_HTML, response.getHeader(HttpHeaders.CONTENT_TYPE)); - - try (InputStream is = part.getInputStream()) { - Assertions.assertEquals(schemas.get(schemaId), IOUtils.toString(is, StandardCharsets.UTF_8)); - } - } - - @Test - public void getStaticResource_notExist() throws IOException { - Response response = inspector.getStaticResource("notExist"); - - InvocationException invocationException = response.getResult(); - Assertions.assertEquals(Status.NOT_FOUND, invocationException.getStatus()); - Assertions.assertEquals(Status.NOT_FOUND.getReasonPhrase(), - ((CommonExceptionData) invocationException.getErrorData()).getMessage()); - Assertions.assertEquals(404, response.getStatusCode()); - Assertions.assertEquals("Not Found", response.getReasonPhrase()); - } - - @Test - public void getStaticResource() throws IOException { - Response response = inspector.getStaticResource("index.html"); - - Part part = response.getResult(); - Assertions.assertEquals("inline", response.getHeader(HttpHeaders.CONTENT_DISPOSITION)); - Assertions.assertEquals(MediaType.TEXT_HTML, response.getHeader(HttpHeaders.CONTENT_TYPE)); - - try (InputStream is = part.getInputStream()) { - Assertions.assertTrue(IOUtils.toString(is, StandardCharsets.UTF_8).endsWith("</html>")); - } - } - - @Test - public void urlPrefix() { - Mockito.when(environment.getProperty("servicecomb.transport.eventloop.size", int.class, -1)) - .thenReturn(-1); - Mockito.when(environment.getProperty(FileResolverImpl.DISABLE_CP_RESOLVING_PROP_NAME, boolean.class, true)) - .thenReturn(true); - InspectorImpl inspector = initInspector("/webroot/rest"); - - Map<String, String> schemas = inspector.getSchemas(); - Assertions.assertTrue(schemas.get("schema1").indexOf("/webroot/rest/metrics") > 0); - } -} diff --git a/inspector/src/test/resources/microservice.yaml b/inspector/src/test/resources/microservice.yaml deleted file mode 100644 index 4db1321ba..000000000 --- a/inspector/src/test/resources/microservice.yaml +++ /dev/null @@ -1,23 +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. -## --------------------------------------------------------------------------- - -servicecomb: - filter-chains: - consumer: - default: empty - producer: - default: empty \ No newline at end of file diff --git a/inspector/src/test/resources/schema1.yaml b/inspector/src/test/resources/schema1.yaml deleted file mode 100644 index 527b8fcd3..000000000 --- a/inspector/src/test/resources/schema1.yaml +++ /dev/null @@ -1,61 +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. -## --------------------------------------------------------------------------- - -openapi: 3.0.1 -info: - title: swagger definition for org.apache.servicecomb.metrics.core.publish.HealthCheckerRestPublisher - version: 1.0.0 -servers: - - url: /metrics -paths: - /: - get: - operationId: checkHealth - responses: - "200": - description: response of 200 - content: - application/json: - schema: - type: boolean - /details: - get: - operationId: checkHealthDetails - responses: - "200": - description: response of 200 - content: - application/json: - schema: - type: object - additionalProperties: - $ref: '#/components/schemas/HealthCheckResult' -components: - schemas: - HealthCheckResult: - type: object - properties: - healthy: - type: boolean - information: - type: string - extraData: - type: string - timestamp: - type: integer - format: int64 - x-java-class: org.apache.servicecomb.foundation.metrics.health.HealthCheckResult diff --git a/inspector/src/test/resources/schema2.yaml b/inspector/src/test/resources/schema2.yaml deleted file mode 100644 index 527b8fcd3..000000000 --- a/inspector/src/test/resources/schema2.yaml +++ /dev/null @@ -1,61 +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. -## --------------------------------------------------------------------------- - -openapi: 3.0.1 -info: - title: swagger definition for org.apache.servicecomb.metrics.core.publish.HealthCheckerRestPublisher - version: 1.0.0 -servers: - - url: /metrics -paths: - /: - get: - operationId: checkHealth - responses: - "200": - description: response of 200 - content: - application/json: - schema: - type: boolean - /details: - get: - operationId: checkHealthDetails - responses: - "200": - description: response of 200 - content: - application/json: - schema: - type: object - additionalProperties: - $ref: '#/components/schemas/HealthCheckResult' -components: - schemas: - HealthCheckResult: - type: object - properties: - healthy: - type: boolean - information: - type: string - extraData: - type: string - timestamp: - type: integer - format: int64 - x-java-class: org.apache.servicecomb.foundation.metrics.health.HealthCheckResult diff --git a/pom.xml b/pom.xml index 7868e523b..b5c2f97fb 100644 --- a/pom.xml +++ b/pom.xml @@ -151,7 +151,6 @@ <module>metrics</module> <module>dynamic-config</module> <module>spring-boot</module> - <module>inspector</module> <module>solutions</module> <module>clients</module> <module>governance</module>