diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..5c4792669 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,31 @@ +# +# 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. +# + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true + +[*.{java, xml, py}] +indent_style = space +indent_size = 4 + +[*.{java, xml}] +# Ignore the IDEA unsupported warning & it works well (indeed) +continuation_indent_size = 8 diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/HugeGraphHubble.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/HugeGraphHubble.java index b0d3e8453..5e25ed8c5 100644 --- a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/HugeGraphHubble.java +++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/HugeGraphHubble.java @@ -48,8 +48,7 @@ public static void initEnv() { } @Override - protected SpringApplicationBuilder configure( - SpringApplicationBuilder builder) { + protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(this.getClass()); } } diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/handler/ExceptionAdvisor.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/handler/ExceptionAdvisor.java index 48d3148dd..5c6030a2d 100644 --- a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/handler/ExceptionAdvisor.java +++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/handler/ExceptionAdvisor.java @@ -18,20 +18,23 @@ package org.apache.hugegraph.handler; -import org.apache.hugegraph.exception.*; +import java.net.ConnectException; + +import org.apache.hugegraph.common.Constant; +import org.apache.hugegraph.common.Response; +import org.apache.hugegraph.exception.ExternalException; +import org.apache.hugegraph.exception.ExternalGenericException; +import org.apache.hugegraph.exception.IllegalGremlinException; +import org.apache.hugegraph.exception.InternalException; +import org.apache.hugegraph.exception.ParameterizedException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestControllerAdvice; -import org.apache.hugegraph.common.Constant; -import org.apache.hugegraph.common.Response; - import lombok.extern.log4j.Log4j2; -import java.net.ConnectException; - @Log4j2 @RestControllerAdvice public class ExceptionAdvisor { @@ -68,10 +71,10 @@ public Response exceptionHandler(ExternalException e) { public Response exceptionHandler(ExternalGenericException e) { log.error("ExternalGenericException:", e); return Response.builder() - .status(e.status()) - .message("An error occurred while trying to connect to the server.") - .cause(null) - .build(); + .status(e.status()) + .message("An error occurred while trying to connect to the server.") + .cause(null) + .build(); } @ExceptionHandler(ConnectException.class) @@ -79,10 +82,10 @@ public Response exceptionHandler(ExternalGenericException e) { public Response exceptionHandler(ConnectException e) { log.error("ConnectException:", e); return Response.builder() - .status(Constant.STATUS_BAD_REQUEST) - .message("An error occurred while trying to connect to the server.") - .cause(null) - .build(); + .status(Constant.STATUS_BAD_REQUEST) + .message("An error occurred while trying to connect to the server.") + .cause(null) + .build(); } @ExceptionHandler(ParameterizedException.class) @@ -109,7 +112,6 @@ public Response exceptionHandler(Exception e) { .build(); } - @ExceptionHandler(IllegalGremlinException.class) @ResponseStatus(HttpStatus.OK) public Response exceptionHandler(IllegalGremlinException e) { diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/HugeClientUtil.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/HugeClientUtil.java index 843f75c0f..452c914c4 100644 --- a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/HugeClientUtil.java +++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/HugeClientUtil.java @@ -31,6 +31,7 @@ import org.apache.hugegraph.rest.ClientException; import org.apache.hugegraph.structure.gremlin.Result; import org.apache.hugegraph.structure.gremlin.ResultSet; + import com.google.common.collect.ImmutableSet; public final class HugeClientUtil { @@ -49,14 +50,11 @@ public static HugeClient tryConnect(GraphConnection connection) { String password = connection.getPassword(); int timeout = connection.getTimeout(); String protocol = connection.getProtocol() == null ? - DEFAULT_PROTOCOL : - connection.getProtocol(); + DEFAULT_PROTOCOL : connection.getProtocol(); String trustStoreFile = connection.getTrustStoreFile(); String trustStorePassword = connection.getTrustStorePassword(); - String url = UriComponentsBuilder.newInstance() - .scheme(protocol) - .host(host).port(port) + String url = UriComponentsBuilder.newInstance().scheme(protocol).host(host).port(port) .toUriString(); if (username == null) { username = ""; @@ -75,7 +73,7 @@ public static HugeClient tryConnect(GraphConnection connection) { throw new ExternalException("client-server.version.unmatched", e); } if (message != null && (message.startsWith("Error loading trust store from") || - message.startsWith("Cannot find trust store file"))) { + message.startsWith("Cannot find trust store file"))) { throw new ExternalException("https.load.truststore.error", e); } throw e; @@ -83,13 +81,10 @@ public static HugeClient tryConnect(GraphConnection connection) { String message = e.getMessage(); if (Constant.STATUS_UNAUTHORIZED == e.status() || (message != null && message.startsWith("Authentication"))) { - throw new ExternalException( - "graph-connection.username-or-password.incorrect", e); + throw new ExternalException("graph-connection.username-or-password.incorrect", e); } - if (message != null && message.contains("Invalid syntax for " + - "username and password")) { - throw new ExternalException( - "graph-connection.missing-username-password", e); + if (message != null && message.contains("Invalid syntax for username and password")) { + throw new ExternalException("graph-connection.missing-username-password", e); } throw new ExternalGenericException(e, host, port); } catch (ClientException e) { @@ -104,8 +99,7 @@ public static HugeClient tryConnect(GraphConnection connection) { message.contains("Host name may not be null")) { throw new ExternalException("service.unknown-host", e, host); } else if (message.contains("")) { - throw new ExternalException("service.suspected-web", - e, host, port); + throw new ExternalException("service.suspected-web", e, host, port); } throw e; } @@ -115,13 +109,11 @@ public static HugeClient tryConnect(GraphConnection connection) { rs.iterator().forEachRemaining(Result::getObject); } catch (ServerException e) { if (Constant.STATUS_UNAUTHORIZED == e.status()) { - throw new ExternalException( - "graph-connection.username-or-password.incorrect", e); + throw new ExternalException("graph-connection.username-or-password.incorrect", e); } String message = e.message(); if (message != null && message.contains("Could not rebind [g]")) { - throw new ExternalException("graph-connection.graph.unexist", e, - graph, host, port); + throw new ExternalException("graph-connection.graph.unexist", e, graph, host, port); } if (!isAcceptable(message)) { throw e; diff --git a/pom.xml b/pom.xml index 7bce7da1c..ad7842874 100644 --- a/pom.xml +++ b/pom.xml @@ -530,6 +530,14 @@ clean + + + remove-flattened-pom + install + + clean + +