From 884166cd575d5cc4a170e703adbd62b19f0e106f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Sun, 13 Aug 2023 18:11:20 +0800 Subject: [PATCH 01/53] Update client-ci.yml add on workflow_dispatch --- .github/workflows/client-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/client-ci.yml b/.github/workflows/client-ci.yml index 15488ae09..4abea8b36 100644 --- a/.github/workflows/client-ci.yml +++ b/.github/workflows/client-ci.yml @@ -1,6 +1,7 @@ name: "hugegraph-client-ci" on: + workflow_dispatch: push: branches: - master From cf729d53b3664faf6c65c7303804d301fa7026f6 Mon Sep 17 00:00:00 2001 From: tianzy Date: Mon, 14 Aug 2023 22:05:22 +0800 Subject: [PATCH 02/53] replace jersey with okhttp --- hugegraph-client/pom.xml | 57 ++- .../apache/hugegraph/api/auth/UserAPI.java | 3 +- .../apache/hugegraph/api/graph/EdgeAPI.java | 13 +- .../apache/hugegraph/api/graph/GraphAPI.java | 12 +- .../apache/hugegraph/api/graph/VertexAPI.java | 30 +- .../hugegraph/api/graphs/GraphsAPI.java | 18 +- .../apache/hugegraph/client/RestClient.java | 9 +- .../apache/hugegraph/driver/HugeClient.java | 7 +- .../hugegraph/exception/ServerException.java | 5 +- .../hugegraph/rest/AbstractRestClient.java | 442 ++++++++++++++++++ .../hugegraph/rest/BasicAuthInterceptor.java | 25 + .../apache/hugegraph/rest/OkhttpConfig.java | 20 + .../org/apache/hugegraph/rest/RestClient.java | 64 +++ .../org/apache/hugegraph/rest/RestResult.java | 118 +++++ .../hugegraph/rest/TokenInterceptor.java | 24 + 15 files changed, 792 insertions(+), 55 deletions(-) create mode 100644 hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java create mode 100644 hugegraph-client/src/main/java/org/apache/hugegraph/rest/BasicAuthInterceptor.java create mode 100644 hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpConfig.java create mode 100644 hugegraph-client/src/main/java/org/apache/hugegraph/rest/RestClient.java create mode 100644 hugegraph-client/src/main/java/org/apache/hugegraph/rest/RestResult.java create mode 100644 hugegraph-client/src/main/java/org/apache/hugegraph/rest/TokenInterceptor.java diff --git a/hugegraph-client/pom.xml b/hugegraph-client/pom.xml index ec867df2d..a8c5cecac 100644 --- a/hugegraph-client/pom.xml +++ b/hugegraph-client/pom.xml @@ -37,28 +37,77 @@ + 1.18.8 + 4.10.0 org.apache.hugegraph hugegraph-common + + + org.glassfish.jersey.core + jersey-client + + + org.glassfish.jersey.media + jersey-media-json-jackson + + + org.glassfish.jersey.connectors + jersey-apache-connector + + + org.glassfish.jersey.inject + jersey-hk2 + + org.lz4 lz4-java - - org.glassfish.jersey.containers - jersey-container-servlet - org.mockito mockito-core test + + + com.squareup.okhttp3 + okhttp + + + com.squareup.okhttp3 + okhttp-tls + + + com.squareup.okhttp3 + logging-interceptor + + + + org.projectlombok + lombok + ${lombok.version} + true + + + + + + com.squareup.okhttp3 + okhttp-bom + ${okhttp.version} + pom + import + + + + diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java index 30fbb9edc..5b1ea3254 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java @@ -50,7 +50,8 @@ public User get(Object id) { } public UserRole getUserRole(Object id) { - String idEncoded = RestClient.encode(formatEntityId(id)); +// String idEncoded = RestClient.encode(formatEntityId(id)); + String idEncoded = formatEntityId(id); String path = String.join("/", this.path(), idEncoded, "role"); RestResult result = this.client.get(path); return result.readObject(UserRole.class); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java index f55f17043..99bcb669c 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java @@ -21,6 +21,7 @@ import java.util.List; import java.util.Map; +import okhttp3.Headers; import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.NotAllCreatedException; import org.apache.hugegraph.rest.RestResult; @@ -32,8 +33,6 @@ import com.google.common.collect.ImmutableMap; -import jakarta.ws.rs.core.MultivaluedHashMap; - public class EdgeAPI extends GraphAPI { public EdgeAPI(RestClient client, String graph) { @@ -51,8 +50,9 @@ public Edge create(Edge edge) { } public List create(List edges, boolean checkVertex) { - MultivaluedHashMap headers = new MultivaluedHashMap<>(); - headers.putSingle("Content-Encoding", BATCH_ENCODING); +// MultivaluedHashMap headers = new MultivaluedHashMap<>(); +// headers.putSingle("Content-Encoding", BATCH_ENCODING); + Headers headers = new Headers.Builder().add("Content-Encoding", BATCH_ENCODING).build(); Map params = ImmutableMap.of("check_vertex", checkVertex); RestResult result = this.client.post(this.batchPath(), edges, @@ -68,8 +68,9 @@ public List create(List edges, boolean checkVertex) { public List update(BatchEdgeRequest request) { this.client.checkApiVersion("0.45", "batch property update"); - MultivaluedHashMap headers = new MultivaluedHashMap<>(); - headers.putSingle("Content-Encoding", BATCH_ENCODING); +// MultivaluedHashMap headers = new MultivaluedHashMap<>(); +// headers.putSingle("Content-Encoding", BATCH_ENCODING); + Headers headers = new Headers.Builder().add("Content-Encoding", BATCH_ENCODING).build(); RestResult result = this.client.put(this.batchPath(), null, request, headers); return result.readList(this.type(), Edge.class); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java index edea0d6c3..d76929dc2 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java @@ -20,9 +20,6 @@ import java.util.Map; import java.util.UUID; -import org.glassfish.jersey.uri.UriComponent; -import org.glassfish.jersey.uri.UriComponent.Type; - import org.apache.hugegraph.api.API; import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.util.E; @@ -76,10 +73,11 @@ public static String formatProperties(Map properties) { * which will invalidate the jersey's automatic decoding * because it considers the space to be encoded as `%2F` */ - return encode(json); +// return encode(json); + return json; } - public static String encode(String raw) { - return UriComponent.encode(raw, Type.QUERY_PARAM_SPACE_ENCODED); - } +// public static String encode(String raw) { +// return UriComponent.encode(raw, Type.QUERY_PARAM_SPACE_ENCODED); +// } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java index 6f2836837..6c8391a80 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java @@ -17,24 +17,21 @@ package org.apache.hugegraph.api.graph; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - +import com.google.common.collect.ImmutableMap; +import okhttp3.Headers; import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.InvalidResponseException; import org.apache.hugegraph.exception.NotAllCreatedException; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.graph.BatchOlapPropertyRequest; import org.apache.hugegraph.structure.graph.BatchVertexRequest; import org.apache.hugegraph.structure.graph.Vertex; import org.apache.hugegraph.structure.graph.Vertices; -import com.google.common.collect.ImmutableMap; - -import jakarta.ws.rs.core.MultivaluedHashMap; - -import org.apache.hugegraph.rest.RestResult; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; public class VertexAPI extends GraphAPI { @@ -53,8 +50,9 @@ public Vertex create(Vertex vertex) { } public List create(List vertices) { - MultivaluedHashMap headers = new MultivaluedHashMap<>(); - headers.putSingle("Content-Encoding", BATCH_ENCODING); +// MultivaluedHashMap headers = new MultivaluedHashMap<>(); +// headers.putSingle("Content-Encoding", BATCH_ENCODING); + Headers headers = new Headers.Builder().add("Content-Encoding", BATCH_ENCODING).build(); RestResult result = this.client.post(this.batchPath(), vertices, headers); List ids = result.readList(Object.class); @@ -68,8 +66,9 @@ public List create(List vertices) { public List update(BatchVertexRequest request) { this.client.checkApiVersion("0.45", "batch property update"); - MultivaluedHashMap headers = new MultivaluedHashMap<>(); - headers.putSingle("Content-Encoding", BATCH_ENCODING); +// MultivaluedHashMap headers = new MultivaluedHashMap<>(); +// headers.putSingle("Content-Encoding", BATCH_ENCODING); + Headers headers = new Headers.Builder().add("Content-Encoding", BATCH_ENCODING).build(); RestResult result = this.client.put(this.batchPath(), null, request, headers); return result.readList(this.type(), Vertex.class); @@ -77,8 +76,9 @@ public List update(BatchVertexRequest request) { public int update(BatchOlapPropertyRequest request) { this.client.checkApiVersion("0.59", "olap property batch update"); - MultivaluedHashMap headers = new MultivaluedHashMap<>(); - headers.putSingle("Content-Encoding", BATCH_ENCODING); +// MultivaluedHashMap headers = new MultivaluedHashMap<>(); +// headers.putSingle("Content-Encoding", BATCH_ENCODING); + Headers headers = new Headers.Builder().add("Content-Encoding", BATCH_ENCODING).build(); String path = String.join("/", this.path(), "olap/batch"); RestResult result = this.client.put(path, null, request, headers); Object size = result.readObject(Map.class).get("size"); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java index 16101b7ec..19b073633 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java @@ -17,15 +17,9 @@ package org.apache.hugegraph.api.graphs; -import java.util.List; -import java.util.Map; - -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; -import jakarta.ws.rs.core.MultivaluedHashMap; - +import com.google.common.collect.ImmutableMap; +import okhttp3.Headers; import org.apache.commons.lang3.StringUtils; - import org.apache.hugegraph.api.API; import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.InvalidResponseException; @@ -34,7 +28,8 @@ import org.apache.hugegraph.structure.constant.GraphReadMode; import org.apache.hugegraph.structure.constant.HugeType; -import com.google.common.collect.ImmutableMap; +import java.util.List; +import java.util.Map; public class GraphsAPI extends API { @@ -59,8 +54,9 @@ protected String type() { public Map create(String name, String cloneGraphName, String configText) { this.client.checkApiVersion("0.67", "dynamic graph add"); - MultivaluedHashMap headers = new MultivaluedHashMap<>(); - headers.add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN); +// MultivaluedHashMap headers = new MultivaluedHashMap<>(); +// headers.add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN); + Headers headers = new Headers.Builder().add("Content-Type", "text/plain").build(); Map params = null; if (StringUtils.isNotEmpty(cloneGraphName)) { params = ImmutableMap.of("clone_graph_name", cloneGraphName); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java index 22650816f..d54a1f5d9 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java @@ -17,6 +17,7 @@ package org.apache.hugegraph.client; +import okhttp3.Response; import org.apache.hugegraph.exception.ServerException; import org.apache.hugegraph.serializer.PathDeserializer; import org.apache.hugegraph.structure.graph.Path; @@ -29,8 +30,6 @@ import com.fasterxml.jackson.databind.module.SimpleModule; -import jakarta.ws.rs.core.Response; - public class RestClient extends AbstractRestClient { private static final int SECOND = 1000; @@ -79,10 +78,10 @@ public boolean apiVersionLt(String minVersion) { } @Override - protected void checkStatus(Response response, Response.Status... statuses) { + protected void checkStatus(Response response, int... statuses) { boolean match = false; - for (Response.Status status : statuses) { - if (status.getStatusCode() == response.getStatus()) { + for (int status : statuses) { + if (status == response.code()) { match = true; break; } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java index e3c9045bf..ff525f71e 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java @@ -19,14 +19,14 @@ import java.io.Closeable; +import lombok.extern.slf4j.Slf4j; import org.apache.hugegraph.version.ClientVersion; import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.ClientException; import org.apache.hugegraph.util.VersionUtil; -import jakarta.ws.rs.ProcessingException; - +@Slf4j public class HugeClient implements Closeable { static { @@ -60,7 +60,8 @@ public HugeClient(HugeClientBuilder builder) { builder.maxConnsPerRoute(), builder.trustStoreFile(), builder.trustStorePassword()); - } catch (ProcessingException e) { + } catch (Exception e) { + log.error("", e); throw new ClientException("Failed to connect url '%s'", builder.url()); } try { diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java index 1e0ac5787..2ba988cd4 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java @@ -19,10 +19,9 @@ import java.util.Map; +import okhttp3.Response; import org.apache.hugegraph.rest.RestResult; -import jakarta.ws.rs.core.Response; - public class ServerException extends RuntimeException { private static final long serialVersionUID = 6335623004322652358L; @@ -43,7 +42,7 @@ public class ServerException extends RuntimeException { public static ServerException fromResponse(Response response) { RestResult rs = new RestResult(response); ServerException exception = new ServerException(rs.content()); - exception.status(response.getStatus()); + exception.status(response.code()); try { @SuppressWarnings("unchecked") Map json = rs.readObject(Map.class); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java new file mode 100644 index 000000000..33d54378e --- /dev/null +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java @@ -0,0 +1,442 @@ +/* + * 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.hugegraph.rest; + +import com.google.common.collect.ImmutableMap; +import lombok.SneakyThrows; +import okhttp3.*; +import okio.BufferedSink; +import okio.GzipSink; +import okio.Okio; +import org.apache.commons.lang3.StringUtils; +import org.apache.hugegraph.util.JsonUtil; + +import javax.net.ssl.*; +import java.io.IOException; +import java.net.URI; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.Collection; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +public abstract class AbstractRestClient implements RestClient { + +// private static final CloseableHttpClient httpclient = HttpClients.createMinimal(); + + private OkHttpClient client; + +// Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 8888)); +// OkHttpClient client = new OkHttpClient.Builder().proxy(proxy).build(); + + private String baseUrl; + + public AbstractRestClient(String url, int timeout) { + this(url, OkhttpConfig.builder() + .timeout(timeout) + .build()); + } + + public AbstractRestClient(String url, String user, String password, + Integer timeout) { + this(url, OkhttpConfig.builder() + .user(user).password(password) + .timeout(timeout) + .build()); + } + + public AbstractRestClient(String url, int timeout, + int maxTotal, int maxPerRoute) { + this(url, null, null, timeout, maxTotal, maxPerRoute); + } + + public AbstractRestClient(String url, Integer timeout, Integer idleTime, + Integer maxTotal, Integer maxPerRoute) { + this(url, OkhttpConfig.builder() + .idleTime(idleTime) + .timeout(timeout) + .maxTotal(maxTotal) + .maxPerRoute(maxPerRoute) + .build()); + } + + public AbstractRestClient(String url, String user, String password, + Integer timeout, Integer maxTotal, Integer maxPerRoute) { + this(url, OkhttpConfig.builder() + .user(user).password(password) + .timeout(timeout) + .maxTotal(maxTotal) + .maxPerRoute(maxPerRoute) + .build()); + } + + public AbstractRestClient(String url, String user, String password, + Integer timeout, Integer maxTotal, Integer maxPerRoute, + String trustStoreFile, + String trustStorePassword) { + this(url, OkhttpConfig.builder() + .user(user).password(password) + .timeout(timeout) + .maxTotal(maxTotal) + .maxPerRoute(maxPerRoute) + .trustStoreFile(trustStoreFile) + .trustStorePassword(trustStorePassword) + .build()); + } + + public AbstractRestClient(String url, String token, Integer timeout) { + this(url, OkhttpConfig.builder() + .token(token) + .timeout(timeout) + .build()); + } + + public AbstractRestClient(String url, String token, Integer timeout, + Integer maxTotal, Integer maxPerRoute) { + this(url,OkhttpConfig.builder() + .token(token) + .timeout(timeout) + .maxTotal(maxTotal) + .maxPerRoute(maxPerRoute) + .build()); + } + + public AbstractRestClient(String url, String token, Integer timeout, + Integer maxTotal, Integer maxPerRoute, + String trustStoreFile, + String trustStorePassword) { + this(url,OkhttpConfig.builder() + .token(token) + .timeout(timeout) + .maxTotal(maxTotal) + .maxPerRoute(maxPerRoute) + .trustStoreFile(trustStoreFile) + .trustStorePassword(trustStorePassword) + .build()); + } + + public AbstractRestClient(String url, OkhttpConfig okhttpConfig) { + this.baseUrl = url; + this.client = getOkhttpClient(okhttpConfig); + } + + private OkHttpClient getOkhttpClient(OkhttpConfig okhttpConfig) { + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + + if(okhttpConfig.getTimeout()!=null) { + builder.connectTimeout(okhttpConfig.getTimeout(), TimeUnit.MILLISECONDS) + .readTimeout(okhttpConfig.getTimeout(), TimeUnit.MILLISECONDS); + } + + if(okhttpConfig.getIdleTime()!=null) { + ConnectionPool connectionPool = new ConnectionPool(5, okhttpConfig.getIdleTime(), TimeUnit.MILLISECONDS); + builder.connectionPool(connectionPool); + } + + + //auth + if(StringUtils.isNotBlank(okhttpConfig.getUser()) && StringUtils.isNotBlank(okhttpConfig.getPassword())) { + builder.addInterceptor(new BasicAuthInterceptor(okhttpConfig.getUser(), okhttpConfig.getPassword())); + } + if(StringUtils.isNotBlank(okhttpConfig.getToken())) { + builder.addInterceptor(new TokenInterceptor(okhttpConfig.getToken())); + } + + OkHttpClient okHttpClient = builder.build(); + + if(okhttpConfig.getMaxTotal()!=null) { + okHttpClient.dispatcher().setMaxRequests(okhttpConfig.getMaxTotal()); + } + + if(okhttpConfig.getMaxPerRoute()!=null) { + okHttpClient.dispatcher().setMaxRequestsPerHost(okhttpConfig.getMaxPerRoute()); + } + + return okHttpClient; + } + + @Override + public RestResult post(String path, Object object) { + return this.post(path, object, null, null); + } + + @Override + public RestResult post(String path, Object object, Headers headers) { + return this.post(path, object, headers, null); + } + + @Override + public RestResult post(String path, Object object, Map params) { + return this.post(path, object, null, params); + } + + private Request.Builder getRequestBuilder(String path, String id, Headers headers, Map params ) { + HttpUrl.Builder urlBuilder = HttpUrl.parse(baseUrl).newBuilder() + .addPathSegments(path); + if(id!=null) { + urlBuilder.addPathSegment(id); + } + + if(params!=null) { + params.forEach((name, value) -> { + if(value==null){ + return; + } + + if(value instanceof Collection) { + for (Object i : (Collection) value) { + urlBuilder.addQueryParameter(name, String.valueOf(i)); + } + } else { + urlBuilder.addQueryParameter(name, String.valueOf(value)); + } + }); + } + + Request.Builder builder = new Request.Builder() + .url(urlBuilder.build()); + + if(headers!=null) { + builder.headers(headers); + } + + this.attachAuthToRequest(builder); + + return builder; + } + + private static RequestBody getRequestBody(Object object, Headers headers) { + String contentType = parseContentType(headers); + String bodyContent = "application/json".equals(contentType) ? JsonUtil.toJson(object) : String.valueOf(object); + + RequestBody requestBody = RequestBody.create(MediaType.parse(contentType), bodyContent); + if(headers!=null && "gzip".equals(headers.get("Content-Encoding"))) { + requestBody = gzip(requestBody); + } + return requestBody; + } + + private static RequestBody gzip(final RequestBody body) { + return new RequestBody() { + @Override public MediaType contentType() { + return body.contentType(); + } + + @Override public long contentLength() { + return -1; // We don't know the compressed length in advance! + } + + @Override public void writeTo(BufferedSink sink) throws IOException { + BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); + body.writeTo(gzipSink); + gzipSink.close(); + } + }; + } + + @SneakyThrows + @Override + public RestResult post(String path, Object object, + Headers headers, + Map params) { + Request.Builder requestBuilder = getRequestBuilder(path, null, headers, params); + requestBuilder.post(getRequestBody(object, headers)); + + try (Response response = client.newCall(requestBuilder.build()).execute()) { + checkStatus(response, 200, 201, 202); + return new RestResult(response); + } + } + + @Override + public RestResult put(String path, String id, Object object) { + return this.put(path, id, object, ImmutableMap.of()); + } + + @Override + public RestResult put(String path, String id, Object object, + Headers headers) { + return this.put(path, id, object, headers, null); + } + + @Override + public RestResult put(String path, String id, Object object, + Map params) { + return this.put(path, id, object, null, params); + } + + @SneakyThrows + @Override + public RestResult put(String path, String id, Object object, + Headers headers, + Map params) { + Request.Builder requestBuilder = getRequestBuilder(path, id, headers, params); + requestBuilder.put(getRequestBody(object, headers)); + + try (Response response = client.newCall(requestBuilder.build()).execute()) { + checkStatus(response, 200, 202); + return new RestResult(response); + } + } + + private static String parseContentType(Headers headers) { + if(headers!=null) { + String contentType = headers.get("Content-Type"); + if(contentType!=null) { + return contentType; + } + } + return "application/json"; + } + + @Override + public RestResult get(String path) { + return this.get(path, null, ImmutableMap.of()); + } + + @Override + public RestResult get(String path, Map params) { + return this.get(path, null, params); + } + + @Override + public RestResult get(String path, String id) { + return this.get(path, id, ImmutableMap.of()); + } + + @SneakyThrows + private RestResult get(String path, String id, Map params) { + Request.Builder requestBuilder = getRequestBuilder(path, id, null, params); + + try (Response response = client.newCall(requestBuilder.build()).execute()) { + checkStatus(response, 200); + return new RestResult(response); + } + } + + + @Override + public RestResult delete(String path, Map params) { + return this.delete(path, null, params); + } + + @Override + public RestResult delete(String path, String id) { + return this.delete(path, id, ImmutableMap.of()); + } + + @SneakyThrows + private RestResult delete(String path, String id, + Map params) { + Request.Builder requestBuilder = getRequestBuilder(path, id, null, params); + requestBuilder.delete(); + + try (Response response = client.newCall(requestBuilder.build()).execute()) { + checkStatus(response, 204, 202); + return new RestResult(response); + } + } + +// protected abstract void checkStatus(HttpResponse response, int... statuses); + protected abstract void checkStatus(Response response, int... statuses); + + @SneakyThrows + @Override + public void close() { + if(client!=null) { + client.dispatcher().executorService().shutdown(); + client.connectionPool().evictAll(); + if(client.cache()!=null) { + client.cache().close(); + } + } + } + + private final ThreadLocal authContext = + new InheritableThreadLocal<>(); + + public void setAuthContext(String auth) { + this.authContext.set(auth); + } + + public void resetAuthContext() { + this.authContext.remove(); + } + + public String getAuthContext() { + return this.authContext.get(); + } + + private void attachAuthToRequest(Request.Builder builder) { + // Add auth header + String auth = this.getAuthContext(); + if (StringUtils.isNotEmpty(auth)) { + builder.addHeader("Authorization", auth); + } + } + + public static class HostNameVerifier implements HostnameVerifier { + + private final String url; + + public HostNameVerifier(String url) { + if (!url.startsWith("http://") && !url.startsWith("https://")) { + url = "http://" + url; + } + url = URI.create(url).getHost(); + this.url = url; + } + + @Override + public boolean verify(String hostname, SSLSession session) { + if (!this.url.isEmpty() && this.url.endsWith(hostname)) { + return true; + } else { + HostnameVerifier verifier = HttpsURLConnection + .getDefaultHostnameVerifier(); + return verifier.verify(hostname, session); + } + } + } + + private static class NoCheckTrustManager implements X509TrustManager { + + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) + throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) + throws CertificateException { + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return null; + } + + public static TrustManager[] create() { + return new TrustManager[]{new NoCheckTrustManager()}; + } + } + + + + +} diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/BasicAuthInterceptor.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/BasicAuthInterceptor.java new file mode 100644 index 000000000..563250b12 --- /dev/null +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/BasicAuthInterceptor.java @@ -0,0 +1,25 @@ +package org.apache.hugegraph.rest; + +import okhttp3.Credentials; +import okhttp3.Interceptor; +import okhttp3.Request; +import okhttp3.Response; + +import java.io.IOException; + +public class BasicAuthInterceptor implements Interceptor { + + private String credentials; + + public BasicAuthInterceptor(String user, String password) { + this.credentials = Credentials.basic(user, password); + } + + @Override + public Response intercept(Chain chain) throws IOException { + Request request = chain.request(); + Request authenticatedRequest = request.newBuilder() + .header("Authorization", credentials).build(); + return chain.proceed(authenticatedRequest); + } +} diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpConfig.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpConfig.java new file mode 100644 index 000000000..0a3b35cee --- /dev/null +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpConfig.java @@ -0,0 +1,20 @@ +package org.apache.hugegraph.rest; + +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; + +@Builder +@Getter +@Setter +public class OkhttpConfig { + private String user; + private String password; + private String token; + private Integer timeout; + private Integer maxTotal; + private Integer maxPerRoute; + private Integer idleTime; + private String trustStoreFile; + private String trustStorePassword; +} diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/RestClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/RestClient.java new file mode 100644 index 000000000..0f951f842 --- /dev/null +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/RestClient.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.apache.hugegraph.rest; + +import okhttp3.Headers; + +import java.util.Map; + +public interface RestClient { + /** + * Post method + */ + RestResult post(String path, Object object); + + RestResult post(String path, Object object, Headers headers); + RestResult post(String path, Object object, Map params); + + RestResult post(String path, Object object, Headers headers, + Map params); + + /** + * Put method + */ + RestResult put(String path, String id, Object object); + RestResult put(String path, String id, Object object, Headers headers); + + RestResult put(String path, String id, Object object, Map params); + + RestResult put(String path, String id, Object object, Headers headers, + Map params); + + /** + * Get method + */ + RestResult get(String path); + + RestResult get(String path, Map params); + + RestResult get(String path, String id); + + /** + * Delete method + */ + RestResult delete(String path, Map params); + + RestResult delete(String path, String id); + + void close(); +} diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/RestResult.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/RestResult.java new file mode 100644 index 000000000..a284a7ae6 --- /dev/null +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/RestResult.java @@ -0,0 +1,118 @@ +/* + * 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.hugegraph.rest; + +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.Module; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.SneakyThrows; +import okhttp3.Headers; +import okhttp3.Response; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class RestResult { + + private static final ObjectMapper MAPPER = new ObjectMapper(); + + private final int status; + private final Headers headers; + private final String content; + + public RestResult(Response response) { + this(response.code(), getResponseContent(response), response.headers()); + } + + @SneakyThrows + private static String getResponseContent(Response response) { + return response.body().string(); + } + + public RestResult(int status, String content, + Headers headers) { + this.status = status; + this.headers = headers; + this.content = content; + } + + public int status() { + return this.status; + } + + public Headers headers() { + return this.headers; + } + + public String content() { + return this.content; + } + + public T readObject(Class clazz) { + try { + return MAPPER.readValue(this.content, clazz); + } catch (Exception e) { + throw new SerializeException( + "Failed to deserialize: %s", e, this.content); + } + } + + @SuppressWarnings("deprecation") + public List readList(String key, Class clazz) { + try { + JsonNode root = MAPPER.readTree(this.content); + JsonNode element = root.get(key); + if (element == null) { + throw new SerializeException( + "Can't find value of the key: %s in json.", key); + } + JavaType type = MAPPER.getTypeFactory() + .constructParametrizedType(ArrayList.class, + List.class, clazz); + return MAPPER.convertValue(element, type); + } catch (IOException e) { + throw new SerializeException( + "Failed to deserialize %s", e, this.content); + } + } + + @SuppressWarnings("deprecation") + public List readList(Class clazz) { + JavaType type = MAPPER.getTypeFactory() + .constructParametrizedType(ArrayList.class, + List.class, clazz); + try { + return MAPPER.readValue(this.content, type); + } catch (IOException e) { + throw new SerializeException( + "Failed to deserialize %s", e, this.content); + } + } + + @Override + public String toString() { + return String.format("{status=%s, headers=%s, content=%s}", + this.status, this.headers, this.content); + } + + public static void registerModule(Module module) { + MAPPER.registerModule(module); + } +} diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/TokenInterceptor.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/TokenInterceptor.java new file mode 100644 index 000000000..947fb0719 --- /dev/null +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/TokenInterceptor.java @@ -0,0 +1,24 @@ +package org.apache.hugegraph.rest; + +import okhttp3.Interceptor; +import okhttp3.Request; +import okhttp3.Response; + +import java.io.IOException; + +public class TokenInterceptor implements Interceptor { + + private String token; + + public TokenInterceptor(String token) { + this.token = token; + } + + @Override + public Response intercept(Chain chain) throws IOException { + Request request = chain.request(); + Request authenticatedRequest = request.newBuilder() + .header("Authorization", "Bearer "+token).build(); + return chain.proceed(authenticatedRequest); + } +} From 3c1011169ea1da77a1dc4ea48eca158b970f5da4 Mon Sep 17 00:00:00 2001 From: tianzy Date: Mon, 14 Aug 2023 22:18:37 +0800 Subject: [PATCH 03/53] fix test error --- .../apache/hugegraph/unit/RestResultTest.java | 131 ++++++++++-------- 1 file changed, 75 insertions(+), 56 deletions(-) diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java index 360cdc5c9..ae043781a 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java @@ -22,6 +22,7 @@ import java.util.Iterator; import java.util.List; +import lombok.SneakyThrows; import org.apache.hugegraph.driver.GraphManager; import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.serializer.PathDeserializer; @@ -55,7 +56,7 @@ public class RestResultTest extends BaseUnitTest { - private jakarta.ws.rs.core.Response mockResponse; + private okhttp3.Response mockResponse; private static GraphManager graphManager; @BeforeClass @@ -74,7 +75,7 @@ public static GraphManager graph() { @Before public void setup() { // Mock caches - this.mockResponse = Mockito.mock(jakarta.ws.rs.core.Response.class); + this.mockResponse = Mockito.mock(okhttp3.Response.class); } @After @@ -82,6 +83,7 @@ public void teardown() { // pass } + @SneakyThrows @Test public void testReadPropertyKey() { String json = "{" @@ -92,9 +94,9 @@ public void testReadPropertyKey() { + "\"properties\": []" + "}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); @@ -108,6 +110,7 @@ public void testReadPropertyKey() { Assert.assertEquals(Collections.emptySet(), propertyKey.properties()); } + @SneakyThrows @Test public void testReadPropertyKeys() { String json = "{\"propertykeys\": [" @@ -126,9 +129,9 @@ public void testReadPropertyKeys() { + "}" + "]}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); @@ -151,6 +154,7 @@ public void testReadPropertyKeys() { Assert.assertEquals(Collections.emptySet(), propertyKey2.properties()); } + @SneakyThrows @Test public void testReadVertexLabel() { String json = "{" @@ -162,9 +166,9 @@ public void testReadVertexLabel() { + "\"properties\": [\"price\", \"name\", \"lang\"]" + "}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); @@ -180,6 +184,7 @@ public void testReadVertexLabel() { vertexLabel.properties()); } + @SneakyThrows @Test public void testReadVertexLabels() { String json = "{\"vertexlabels\": [" @@ -201,9 +206,9 @@ public void testReadVertexLabels() { + "}" + "]}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); @@ -230,6 +235,7 @@ public void testReadVertexLabels() { vertexLabel2.properties()); } + @SneakyThrows @Test public void testReadEdgeLabel() { String json = "{" @@ -243,9 +249,9 @@ public void testReadEdgeLabel() { + "\"frequency\": \"SINGLE\"" + "}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); @@ -261,6 +267,7 @@ public void testReadEdgeLabel() { Assert.assertEquals(ImmutableSet.of("date"), edgeLabel.properties()); } + @SneakyThrows @Test public void testReadEdgeLabels() { String json = "{\"edgelabels\": [" @@ -285,9 +292,9 @@ public void testReadEdgeLabels() { + "}" + "]}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); @@ -315,6 +322,7 @@ public void testReadEdgeLabels() { edgeLabel2.properties()); } + @SneakyThrows @Test public void testReadIndexLabel() { String json = "{" @@ -326,9 +334,9 @@ public void testReadIndexLabel() { + "\"base_type\": \"VERTEX_LABEL\"" + "}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); @@ -344,6 +352,7 @@ public void testReadIndexLabel() { indexLabel.indexFields()); } + @SneakyThrows @Test public void testReadIndexLabels() { String json = "{\"indexlabels\": [" @@ -365,9 +374,9 @@ public void testReadIndexLabels() { + "}" + "]}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); @@ -394,6 +403,7 @@ public void testReadIndexLabels() { indexLabel2.indexFields()); } + @SneakyThrows @Test public void testReadVertex() { String json = "{" @@ -405,9 +415,9 @@ public void testReadVertex() { + "}" + "}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); @@ -421,6 +431,7 @@ public void testReadVertex() { vertex.properties()); } + @SneakyThrows @Test public void testReadVertices() { String json = "{\"vertices\": [" @@ -456,9 +467,9 @@ public void testReadVertices() { + "}" + "]}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); @@ -497,6 +508,7 @@ public void testReadVertices() { vertex3.properties()); } + @SneakyThrows @Test public void testReadEdge() { String json = "{" @@ -513,9 +525,9 @@ public void testReadEdge() { + "}" + "}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); @@ -534,6 +546,7 @@ public void testReadEdge() { edge.properties()); } + @SneakyThrows @Test public void testReadEdges() { String json = "{\"edges\": [" @@ -564,9 +577,9 @@ public void testReadEdges() { + "}" + "]}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); @@ -597,6 +610,7 @@ public void testReadEdges() { edge2.properties()); } + @SneakyThrows @Test public void testReadGremlinVertices() { String json = "{" @@ -643,9 +657,9 @@ public void testReadGremlinVertices() { + "}" + "}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult restResult = new RestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); @@ -689,6 +703,7 @@ public void testReadGremlinVertices() { } } + @SneakyThrows @Test public void testReadGremlinEdges() { String json = "{" @@ -731,9 +746,9 @@ public void testReadGremlinEdges() { + "}" + "}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult restResult = new RestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); @@ -774,6 +789,7 @@ public void testReadGremlinEdges() { } } + @SneakyThrows @Test public void testReadGremlinPathWithVertexAndEdge() { String json = "{" @@ -819,9 +835,9 @@ public void testReadGremlinPathWithVertexAndEdge() { + "}" + "}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult restResult = new RestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); @@ -862,6 +878,7 @@ public void testReadGremlinPathWithVertexAndEdge() { path.objects()); } + @SneakyThrows @Test public void testReadGremlinNullData() { String json = "{" @@ -877,9 +894,9 @@ public void testReadGremlinNullData() { + "}" + "}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult restResult = new RestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); @@ -895,6 +912,7 @@ public void testReadGremlinNullData() { Assert.assertNull(object); } + @SneakyThrows @Test public void testReadGremlinNullAndVertex() { String json = "{" @@ -922,9 +940,9 @@ public void testReadGremlinNullAndVertex() { + "}" + "}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult restResult = new RestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); @@ -952,6 +970,7 @@ public void testReadGremlinNullAndVertex() { Assert.assertTrue(Utils.contains(ImmutableList.of(marko), vertex)); } + @SneakyThrows @Test public void testReadGremlinEdgeAndNull() { String json = "{" @@ -982,9 +1001,9 @@ public void testReadGremlinEdgeAndNull() { + "}" + "}"; - Mockito.when(this.mockResponse.getStatus()).thenReturn(200); - Mockito.when(this.mockResponse.getHeaders()).thenReturn(null); - Mockito.when(this.mockResponse.readEntity(String.class)) + Mockito.when(this.mockResponse.code()).thenReturn(200); + Mockito.when(this.mockResponse.headers()).thenReturn(null); + Mockito.when(this.mockResponse.body().string()) .thenReturn(json); RestResult restResult = new RestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); From 1eabd9a4927e3ac00b8ea43e2d9a1b200fa5861a Mon Sep 17 00:00:00 2001 From: tianzy Date: Mon, 14 Aug 2023 22:42:05 +0800 Subject: [PATCH 04/53] fix the problem that mockito can't mock final class --- .../src/test/java/org/apache/hugegraph/unit/RestResultTest.java | 2 +- .../resources/mockito-extensions/org.mockito.plugins.MockMaker | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java index ae043781a..60b44ba78 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java @@ -75,7 +75,7 @@ public static GraphManager graph() { @Before public void setup() { // Mock caches - this.mockResponse = Mockito.mock(okhttp3.Response.class); + this.mockResponse = Mockito.mock(okhttp3.Response.class, Mockito.RETURNS_DEEP_STUBS); } @After diff --git a/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker new file mode 100644 index 000000000..1f0955d45 --- /dev/null +++ b/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker @@ -0,0 +1 @@ +mock-maker-inline From ab2f9179f00587c4be7309c43fa719565d348135 Mon Sep 17 00:00:00 2001 From: tianzy Date: Mon, 14 Aug 2023 23:42:13 +0800 Subject: [PATCH 05/53] fix error --- .../org/apache/hugegraph/rest/BasicAuthInterceptor.java | 9 ++++++--- .../java/org/apache/hugegraph/rest/TokenInterceptor.java | 9 ++++++--- .../test/java/org/apache/hugegraph/BaseClientTest.java | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/BasicAuthInterceptor.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/BasicAuthInterceptor.java index 563250b12..83edd3ef7 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/BasicAuthInterceptor.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/BasicAuthInterceptor.java @@ -18,8 +18,11 @@ public BasicAuthInterceptor(String user, String password) { @Override public Response intercept(Chain chain) throws IOException { Request request = chain.request(); - Request authenticatedRequest = request.newBuilder() - .header("Authorization", credentials).build(); - return chain.proceed(authenticatedRequest); + if(request.header("Authorization")==null) { + Request authenticatedRequest = request.newBuilder() + .header("Authorization", credentials).build(); + return chain.proceed(authenticatedRequest); + } + return chain.proceed(request); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/TokenInterceptor.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/TokenInterceptor.java index 947fb0719..578826bfe 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/TokenInterceptor.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/TokenInterceptor.java @@ -17,8 +17,11 @@ public TokenInterceptor(String token) { @Override public Response intercept(Chain chain) throws IOException { Request request = chain.request(); - Request authenticatedRequest = request.newBuilder() - .header("Authorization", "Bearer "+token).build(); - return chain.proceed(authenticatedRequest); + if(request.header("Authorization")==null) { + Request authenticatedRequest = request.newBuilder() + .header("Authorization", "Bearer "+token).build(); + return chain.proceed(authenticatedRequest); + } + return chain.proceed(request); } } diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java index e195d12e8..b44288240 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java @@ -49,7 +49,8 @@ public class BaseClientTest { - protected static final String BASE_URL = "http://127.0.0.1:8080"; +// protected static final String BASE_URL = "http://127.0.0.1:8080"; + protected static final String BASE_URL = "http://172.19.102.150:8080"; protected static final String GRAPH = "hugegraph"; protected static final String USERNAME = "admin"; protected static final String PASSWORD = "pa"; From 3fe0244dabda6e93503eb1ba07acba574e5dd7fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Tue, 15 Aug 2023 16:14:29 +0800 Subject: [PATCH 06/53] Update BaseClientTest.java --- .../src/test/java/org/apache/hugegraph/BaseClientTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java index b44288240..ad5512395 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java @@ -49,8 +49,8 @@ public class BaseClientTest { -// protected static final String BASE_URL = "http://127.0.0.1:8080"; - protected static final String BASE_URL = "http://172.19.102.150:8080"; + protected static final String BASE_URL = "http://127.0.0.1:8080"; +// protected static final String BASE_URL = "http://172.19.102.150:8080"; protected static final String GRAPH = "hugegraph"; protected static final String USERNAME = "admin"; protected static final String PASSWORD = "pa"; From cb79e569121659d3d3bd8f83fef4921a97241189 Mon Sep 17 00:00:00 2001 From: tianzy Date: Thu, 17 Aug 2023 00:25:38 +0800 Subject: [PATCH 07/53] https support && add licence header --- .../hugegraph/rest/AbstractRestClient.java | 81 ++++++++++--------- .../hugegraph/rest/BasicAuthInterceptor.java | 17 ++++ .../apache/hugegraph/rest/OkhttpConfig.java | 17 ++++ .../hugegraph/rest/TokenInterceptor.java | 17 ++++ .../org/apache/hugegraph/BaseClientTest.java | 1 - 5 files changed, 95 insertions(+), 38 deletions(-) diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java index 33d54378e..cddbf8d3d 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java @@ -27,23 +27,19 @@ import org.apache.hugegraph.util.JsonUtil; import javax.net.ssl.*; +import java.io.FileInputStream; import java.io.IOException; import java.net.URI; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; +import java.security.KeyStore; +import java.util.Arrays; import java.util.Collection; import java.util.Map; import java.util.concurrent.TimeUnit; public abstract class AbstractRestClient implements RestClient { -// private static final CloseableHttpClient httpclient = HttpClients.createMinimal(); - private OkHttpClient client; -// Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 8888)); -// OkHttpClient client = new OkHttpClient.Builder().proxy(proxy).build(); - private String baseUrl; public AbstractRestClient(String url, int timeout) { @@ -157,6 +153,9 @@ private OkHttpClient getOkhttpClient(OkhttpConfig okhttpConfig) { builder.addInterceptor(new TokenInterceptor(okhttpConfig.getToken())); } + //ssl + configSsl(builder, baseUrl, okhttpConfig.getTrustStoreFile(), okhttpConfig.getTrustStorePassword()); + OkHttpClient okHttpClient = builder.build(); if(okhttpConfig.getMaxTotal()!=null) { @@ -170,6 +169,21 @@ private OkHttpClient getOkhttpClient(OkhttpConfig okhttpConfig) { return okHttpClient; } + @SneakyThrows + private void configSsl(OkHttpClient.Builder builder, String url, String trustStoreFile, String trustStorePass) { + if(StringUtils.isBlank(trustStoreFile) || StringUtils.isBlank(trustStorePass)) { + return; + } + + X509TrustManager trustManager = trustManagerForCertificates(trustStoreFile, trustStorePass); + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(null, new TrustManager[]{trustManager}, null); + SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); + + builder.sslSocketFactory(sslSocketFactory, trustManager) + .hostnameVerifier(new CustomHostnameVerifier(url)); + } + @Override public RestResult post(String path, Object object) { return this.post(path, object, null, null); @@ -352,7 +366,6 @@ private RestResult delete(String path, String id, } } -// protected abstract void checkStatus(HttpResponse response, int... statuses); protected abstract void checkStatus(Response response, int... statuses); @SneakyThrows @@ -390,11 +403,31 @@ private void attachAuthToRequest(Request.Builder builder) { } } - public static class HostNameVerifier implements HostnameVerifier { + @SneakyThrows + private X509TrustManager trustManagerForCertificates(String trustStoreFile, String trustStorePass){ + char[] password = trustStorePass.toCharArray(); + + //load keyStore + KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); + try(FileInputStream in = new FileInputStream(trustStoreFile)) { + keyStore.load(in, password); + } + + TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + trustManagerFactory.init(keyStore); + + TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); + if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) { + throw new IllegalStateException("Unexpected default trust managers:" + + Arrays.toString(trustManagers)); + } + return (X509TrustManager) trustManagers[0]; + } + private class CustomHostnameVerifier implements HostnameVerifier { private final String url; - public HostNameVerifier(String url) { + public CustomHostnameVerifier(String url) { if (!url.startsWith("http://") && !url.startsWith("https://")) { url = "http://" + url; } @@ -407,36 +440,10 @@ public boolean verify(String hostname, SSLSession session) { if (!this.url.isEmpty() && this.url.endsWith(hostname)) { return true; } else { - HostnameVerifier verifier = HttpsURLConnection - .getDefaultHostnameVerifier(); + HostnameVerifier verifier = HttpsURLConnection.getDefaultHostnameVerifier(); return verifier.verify(hostname, session); } } } - private static class NoCheckTrustManager implements X509TrustManager { - - @Override - public void checkClientTrusted(X509Certificate[] chain, String authType) - throws CertificateException { - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) - throws CertificateException { - } - - @Override - public X509Certificate[] getAcceptedIssuers() { - return null; - } - - public static TrustManager[] create() { - return new TrustManager[]{new NoCheckTrustManager()}; - } - } - - - - } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/BasicAuthInterceptor.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/BasicAuthInterceptor.java index 83edd3ef7..12477263b 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/BasicAuthInterceptor.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/BasicAuthInterceptor.java @@ -1,3 +1,20 @@ +/* + * 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.hugegraph.rest; import okhttp3.Credentials; diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpConfig.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpConfig.java index 0a3b35cee..5d5c62da9 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpConfig.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpConfig.java @@ -1,3 +1,20 @@ +/* + * 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.hugegraph.rest; import lombok.Builder; diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/TokenInterceptor.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/TokenInterceptor.java index 578826bfe..f9317ff62 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/TokenInterceptor.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/TokenInterceptor.java @@ -1,3 +1,20 @@ +/* + * 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.hugegraph.rest; import okhttp3.Interceptor; diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java index ad5512395..e195d12e8 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java @@ -50,7 +50,6 @@ public class BaseClientTest { protected static final String BASE_URL = "http://127.0.0.1:8080"; -// protected static final String BASE_URL = "http://172.19.102.150:8080"; protected static final String GRAPH = "hugegraph"; protected static final String USERNAME = "admin"; protected static final String PASSWORD = "pa"; From 552a10862c8c26e3b3cba6a18c2613b81cf636d0 Mon Sep 17 00:00:00 2001 From: tianzy Date: Thu, 17 Aug 2023 01:00:26 +0800 Subject: [PATCH 08/53] fix licence check error --- hugegraph-client/pom.xml | 4 ---- .../org.mockito.plugins.MockMaker | 17 +++++++++++++++++ .../scripts/dependency/known-dependencies.txt | 13 +++++++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/hugegraph-client/pom.xml b/hugegraph-client/pom.xml index a8c5cecac..c8186ddf9 100644 --- a/hugegraph-client/pom.xml +++ b/hugegraph-client/pom.xml @@ -78,10 +78,6 @@ com.squareup.okhttp3 okhttp - - com.squareup.okhttp3 - okhttp-tls - com.squareup.okhttp3 logging-interceptor diff --git a/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker index 1f0955d45..4143cebcf 100644 --- a/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +++ b/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker @@ -1 +1,18 @@ +/* + * 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. + */ + mock-maker-inline diff --git a/hugegraph-dist/scripts/dependency/known-dependencies.txt b/hugegraph-dist/scripts/dependency/known-dependencies.txt index 6a67bf292..2409e442b 100644 --- a/hugegraph-dist/scripts/dependency/known-dependencies.txt +++ b/hugegraph-dist/scripts/dependency/known-dependencies.txt @@ -7,6 +7,7 @@ accessors-smart-2.4.2.jar aircompressor-0.10.jar aircompressor-0.21.jar annotations-17.0.0.jar +annotations-13.0.jar ant-1.9.1.jar ant-launcher-1.9.1.jar antlr-runtime-3.5.2.jar @@ -140,7 +141,6 @@ jakarta.activation-2.0.1.jar jakarta.activation-api-1.2.1.jar jakarta.annotation-api-2.0.0.jar jakarta.inject-api-2.0.0.jar -jakarta.validation-api-3.0.0.jar jakarta.ws.rs-api-3.0.0.jar jakarta.xml.bind-api-2.3.2.jar jakarta.xml.bind-api-4.0.0-RC2.jar @@ -174,7 +174,6 @@ jersey-container-servlet-core-3.0.3.jar jersey-entity-filtering-3.0.3.jar jersey-hk2-3.0.3.jar jersey-media-json-jackson-3.0.3.jar -jersey-server-3.0.3.jar jetty-client-9.4.33.v20201020.jar jetty-client-9.4.40.v20210413.jar jetty-http-9.4.19.v20190610.jar @@ -267,7 +266,17 @@ netty-transport-native-epoll-4.1.65.Final.jar netty-transport-native-unix-common-4.1.65.Final.jar nimbus-jose-jwt-9.8.1.jar okhttp-2.7.5.jar +okhttp-4.10.0.jar +logging-interceptor-4.10.0.jar +kotlin-stdlib-1.2.71.jar +kotlin-stdlib-1.6.20.jar +kotlin-stdlib-common-1.5.31.jar +kotlin-stdlib-jdk7-1.2.71.jar +kotlin-stdlib-jdk7-1.6.10.jar +kotlin-stdlib-jdk8-1.2.71.jar +kotlin-stdlib-jdk8-1.6.10.jar okio-1.6.0.jar +okio-jvm-3.0.0.jar opencsv-2.3.jar orc-core-1.5.8.jar orc-core-1.6.14.jar From 9d211f883db5c99d9d6cc4c52f9ff28def373c30 Mon Sep 17 00:00:00 2001 From: tianzy Date: Thu, 17 Aug 2023 01:12:43 +0800 Subject: [PATCH 09/53] fix error --- .../org.mockito.plugins.MockMaker | 17 ----------------- .../scripts/dependency/known-dependencies.txt | 1 - 2 files changed, 18 deletions(-) diff --git a/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker index 4143cebcf..1f0955d45 100644 --- a/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +++ b/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker @@ -1,18 +1 @@ -/* - * 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. - */ - mock-maker-inline diff --git a/hugegraph-dist/scripts/dependency/known-dependencies.txt b/hugegraph-dist/scripts/dependency/known-dependencies.txt index 2409e442b..d849580f1 100644 --- a/hugegraph-dist/scripts/dependency/known-dependencies.txt +++ b/hugegraph-dist/scripts/dependency/known-dependencies.txt @@ -169,7 +169,6 @@ jcommander-1.78.jar jersey-apache-connector-3.0.3.jar jersey-client-3.0.3.jar jersey-common-3.0.3.jar -jersey-container-servlet-3.0.3.jar jersey-container-servlet-core-3.0.3.jar jersey-entity-filtering-3.0.3.jar jersey-hk2-3.0.3.jar From a9c6c88abbf260f7477e62ee7d8b796d8752063c Mon Sep 17 00:00:00 2001 From: tianzy Date: Thu, 17 Aug 2023 01:47:50 +0800 Subject: [PATCH 10/53] fix licence check error --- .licenserc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.licenserc.yaml b/.licenserc.yaml index 789856df7..827be9c86 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -75,6 +75,7 @@ header: # `header` section is configurations for source codes license header. - 'assembly/**' - '.github/**/*' - '**/target/*' + - 'hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker' # - 'hugegraph-hubble/hubble-fe/**' comment: on-failure # on what condition license-eye will comment on the pull request, `on-failure`, `always`, `never`. From bd5e5e75cd0d595a37c221553b0679bbfe3638b6 Mon Sep 17 00:00:00 2001 From: tianzy Date: Thu, 17 Aug 2023 19:43:39 +0800 Subject: [PATCH 11/53] fix error --- .../hugegraph/rest/AbstractRestClient.java | 8 ++++---- .../org.mockito.plugins.MockMaker | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java index cddbf8d3d..5020149c7 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java @@ -61,8 +61,8 @@ public AbstractRestClient(String url, int timeout, this(url, null, null, timeout, maxTotal, maxPerRoute); } - public AbstractRestClient(String url, Integer timeout, Integer idleTime, - Integer maxTotal, Integer maxPerRoute) { + public AbstractRestClient(String url, int timeout, int idleTime, + int maxTotal, int maxPerRoute) { this(url, OkhttpConfig.builder() .idleTime(idleTime) .timeout(timeout) @@ -72,7 +72,7 @@ public AbstractRestClient(String url, Integer timeout, Integer idleTime, } public AbstractRestClient(String url, String user, String password, - Integer timeout, Integer maxTotal, Integer maxPerRoute) { + int timeout, int maxTotal, int maxPerRoute) { this(url, OkhttpConfig.builder() .user(user).password(password) .timeout(timeout) @@ -82,7 +82,7 @@ public AbstractRestClient(String url, String user, String password, } public AbstractRestClient(String url, String user, String password, - Integer timeout, Integer maxTotal, Integer maxPerRoute, + int timeout, int maxTotal, int maxPerRoute, String trustStoreFile, String trustStorePassword) { this(url, OkhttpConfig.builder() diff --git a/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker index 1f0955d45..a76010b24 100644 --- a/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +++ b/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker @@ -1 +1,17 @@ +# +# 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. +# mock-maker-inline From 277fe04eee9dd3e70559616ed2952835cc574fc4 Mon Sep 17 00:00:00 2001 From: tianzy Date: Thu, 17 Aug 2023 20:37:52 +0800 Subject: [PATCH 12/53] rename rest class && remove jersey dependency --- .../java/org/apache/hugegraph/api/API.java | 6 +- .../apache/hugegraph/api/auth/AccessAPI.java | 14 +-- .../apache/hugegraph/api/auth/AuthAPI.java | 4 +- .../apache/hugegraph/api/auth/BelongAPI.java | 14 +-- .../apache/hugegraph/api/auth/GroupAPI.java | 14 +-- .../apache/hugegraph/api/auth/LoginAPI.java | 8 +- .../apache/hugegraph/api/auth/LogoutAPI.java | 4 +- .../apache/hugegraph/api/auth/ProjectAPI.java | 18 ++-- .../apache/hugegraph/api/auth/TargetAPI.java | 14 +-- .../apache/hugegraph/api/auth/TokenAPI.java | 8 +- .../apache/hugegraph/api/auth/UserAPI.java | 16 +-- .../apache/hugegraph/api/graph/EdgeAPI.java | 20 ++-- .../apache/hugegraph/api/graph/GraphAPI.java | 4 +- .../apache/hugegraph/api/graph/VertexAPI.java | 22 ++-- .../hugegraph/api/graphs/GraphsAPI.java | 16 +-- .../hugegraph/api/gremlin/CypherAPI.java | 8 +- .../hugegraph/api/gremlin/GremlinAPI.java | 8 +- .../hugegraph/api/job/GremlinJobAPI.java | 8 +- .../org/apache/hugegraph/api/job/JobAPI.java | 4 +- .../apache/hugegraph/api/job/RebuildAPI.java | 8 +- .../hugegraph/api/metrics/MetricsAPI.java | 12 +-- .../hugegraph/api/schema/EdgeLabelAPI.java | 20 ++-- .../hugegraph/api/schema/IndexLabelAPI.java | 20 ++-- .../hugegraph/api/schema/PropertyKeyAPI.java | 22 ++-- .../hugegraph/api/schema/SchemaAPI.java | 8 +- .../api/schema/SchemaElementAPI.java | 4 +- .../hugegraph/api/schema/VertexLabelAPI.java | 20 ++-- .../apache/hugegraph/api/task/TaskAPI.java | 16 +-- .../api/traverser/AllShortestPathsAPI.java | 8 +- .../hugegraph/api/traverser/CountAPI.java | 8 +- .../api/traverser/CrosspointsAPI.java | 8 +- .../traverser/CustomizedCrosspointsAPI.java | 8 +- .../api/traverser/CustomizedPathsAPI.java | 8 +- .../hugegraph/api/traverser/EdgesAPI.java | 12 +-- .../api/traverser/FusiformSimilarityAPI.java | 8 +- .../api/traverser/JaccardSimilarityAPI.java | 10 +- .../hugegraph/api/traverser/KneighborAPI.java | 10 +- .../hugegraph/api/traverser/KoutAPI.java | 10 +- .../traverser/MultiNodeShortestPathAPI.java | 8 +- .../api/traverser/NeighborRankAPI.java | 8 +- .../hugegraph/api/traverser/PathsAPI.java | 10 +- .../api/traverser/PersonalRankAPI.java | 8 +- .../hugegraph/api/traverser/RaysAPI.java | 8 +- .../hugegraph/api/traverser/RingsAPI.java | 8 +- .../api/traverser/SameNeighborsAPI.java | 8 +- .../api/traverser/ShortestPathAPI.java | 8 +- .../SingleSourceShortestPathAPI.java | 8 +- .../api/traverser/TemplatePathsAPI.java | 8 +- .../api/traverser/TraversersAPI.java | 4 +- .../hugegraph/api/traverser/VerticesAPI.java | 12 +-- .../traverser/WeightedShortestPathAPI.java | 8 +- .../hugegraph/api/variables/VariablesAPI.java | 12 +-- .../hugegraph/api/version/VersionAPI.java | 8 +- ...lient.java => OkhttpOkhttpRestClient.java} | 18 ++-- .../apache/hugegraph/driver/AuthManager.java | 4 +- .../hugegraph/driver/CypherManager.java | 4 +- .../apache/hugegraph/driver/GraphManager.java | 4 +- .../hugegraph/driver/GraphsManager.java | 4 +- .../hugegraph/driver/GremlinManager.java | 4 +- .../apache/hugegraph/driver/HugeClient.java | 8 +- .../apache/hugegraph/driver/JobManager.java | 4 +- .../hugegraph/driver/MetricsManager.java | 4 +- .../hugegraph/driver/SchemaManager.java | 4 +- .../apache/hugegraph/driver/TaskManager.java | 4 +- .../hugegraph/driver/TraverserManager.java | 4 +- .../hugegraph/driver/VariablesManager.java | 4 +- .../hugegraph/driver/VersionManager.java | 4 +- .../hugegraph/exception/ServerException.java | 4 +- ...va => AbstractOkhttpOkhttpRestClient.java} | 100 +++++++++--------- ...r.java => OkhttpBasicAuthInterceptor.java} | 4 +- ...{RestClient.java => OkhttpRestClient.java} | 32 +++--- ...{RestResult.java => OkhttpRestResult.java} | 8 +- ...eptor.java => OkhttpTokenInterceptor.java} | 4 +- .../org/apache/hugegraph/api/BaseApiTest.java | 10 +- .../hugegraph/api/auth/LogoutApiTest.java | 4 +- .../hugegraph/api/auth/TokenApiTest.java | 6 +- .../apache/hugegraph/unit/RestResultTest.java | 40 +++---- hugegraph-hubble/hubble-be/pom.xml | 18 ++++ hugegraph-hubble/pom.xml | 14 +-- pom.xml | 34 ++++-- 80 files changed, 472 insertions(+), 436 deletions(-) rename hugegraph-client/src/main/java/org/apache/hugegraph/client/{RestClient.java => OkhttpOkhttpRestClient.java} (82%) rename hugegraph-client/src/main/java/org/apache/hugegraph/rest/{AbstractRestClient.java => AbstractOkhttpOkhttpRestClient.java} (77%) rename hugegraph-client/src/main/java/org/apache/hugegraph/rest/{BasicAuthInterceptor.java => OkhttpBasicAuthInterceptor.java} (91%) rename hugegraph-client/src/main/java/org/apache/hugegraph/rest/{RestClient.java => OkhttpRestClient.java} (50%) rename hugegraph-client/src/main/java/org/apache/hugegraph/rest/{RestResult.java => OkhttpRestResult.java} (95%) rename hugegraph-client/src/main/java/org/apache/hugegraph/rest/{TokenInterceptor.java => OkhttpTokenInterceptor.java} (92%) diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/API.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/API.java index 1f9d5025d..7f2aea9ec 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/API.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/API.java @@ -17,7 +17,7 @@ package org.apache.hugegraph.api; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.util.E; public abstract class API { @@ -27,11 +27,11 @@ public abstract class API { public static final long NO_LIMIT = -1L; public static final String PATH_SPLITOR = "/"; - protected final RestClient client; + protected final OkhttpOkhttpRestClient client; private String path; - public API(RestClient client) { + public API(OkhttpOkhttpRestClient client) { E.checkNotNull(client, "client"); this.client = client; this.path = null; diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AccessAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AccessAPI.java index 78a32cbed..fe8fca28c 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AccessAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AccessAPI.java @@ -21,14 +21,14 @@ import java.util.List; import java.util.Map; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.auth.Access; import org.apache.hugegraph.structure.constant.HugeType; public class AccessAPI extends AuthAPI { - public AccessAPI(RestClient client, String graph) { + public AccessAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -38,12 +38,12 @@ protected String type() { } public Access create(Access access) { - RestResult result = this.client.post(this.path(), access); + OkhttpRestResult result = this.client.post(this.path(), access); return result.readObject(Access.class); } public Access get(Object id) { - RestResult result = this.client.get(this.path(), formatRelationId(id)); + OkhttpRestResult result = this.client.get(this.path(), formatRelationId(id)); return result.readObject(Access.class); } @@ -53,13 +53,13 @@ public List list(Object group, Object target, int limit) { params.put("limit", limit); params.put("group", formatEntityId(group)); params.put("target", formatEntityId(target)); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Access.class); } public Access update(Access access) { String id = formatRelationId(access.id()); - RestResult result = this.client.put(this.path(), id, access); + OkhttpRestResult result = this.client.put(this.path(), id, access); return result.readObject(Access.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AuthAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AuthAPI.java index 655b4eaf5..f787bec8e 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AuthAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AuthAPI.java @@ -18,14 +18,14 @@ package org.apache.hugegraph.api.auth; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.structure.auth.AuthElement; public abstract class AuthAPI extends API { private static final String PATH = "graphs/%s/auth/%s"; - public AuthAPI(RestClient client, String graph) { + public AuthAPI(OkhttpOkhttpRestClient client, String graph) { super(client); this.path(PATH, graph, this.type()); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/BelongAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/BelongAPI.java index bcf18d9d9..322d1b60e 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/BelongAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/BelongAPI.java @@ -21,14 +21,14 @@ import java.util.List; import java.util.Map; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.auth.Belong; import org.apache.hugegraph.structure.constant.HugeType; public class BelongAPI extends AuthAPI { - public BelongAPI(RestClient client, String graph) { + public BelongAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -38,12 +38,12 @@ protected String type() { } public Belong create(Belong belong) { - RestResult result = this.client.post(this.path(), belong); + OkhttpRestResult result = this.client.post(this.path(), belong); return result.readObject(Belong.class); } public Belong get(Object id) { - RestResult result = this.client.get(this.path(), formatRelationId(id)); + OkhttpRestResult result = this.client.get(this.path(), formatRelationId(id)); return result.readObject(Belong.class); } @@ -53,13 +53,13 @@ public List list(Object user, Object group, int limit) { params.put("limit", limit); params.put("user", formatEntityId(user)); params.put("group", formatEntityId(group)); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Belong.class); } public Belong update(Belong belong) { String id = formatRelationId(belong.id()); - RestResult result = this.client.put(this.path(), id, belong); + OkhttpRestResult result = this.client.put(this.path(), id, belong); return result.readObject(Belong.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/GroupAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/GroupAPI.java index 416f941db..9f09d04db 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/GroupAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/GroupAPI.java @@ -20,8 +20,8 @@ import java.util.List; import java.util.Map; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.auth.Group; import org.apache.hugegraph.structure.constant.HugeType; @@ -29,7 +29,7 @@ public class GroupAPI extends AuthAPI { - public GroupAPI(RestClient client, String graph) { + public GroupAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -39,25 +39,25 @@ protected String type() { } public Group create(Group group) { - RestResult result = this.client.post(this.path(), group); + OkhttpRestResult result = this.client.post(this.path(), group); return result.readObject(Group.class); } public Group get(Object id) { - RestResult result = this.client.get(this.path(), formatEntityId(id)); + OkhttpRestResult result = this.client.get(this.path(), formatEntityId(id)); return result.readObject(Group.class); } public List list(int limit) { checkLimit(limit, "Limit"); Map params = ImmutableMap.of("limit", limit); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Group.class); } public Group update(Group group) { String id = formatEntityId(group.id()); - RestResult result = this.client.put(this.path(), id, group); + OkhttpRestResult result = this.client.put(this.path(), id, group); return result.readObject(Group.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LoginAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LoginAPI.java index e7996e689..ef4e608fb 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LoginAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LoginAPI.java @@ -17,15 +17,15 @@ package org.apache.hugegraph.api.auth; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.auth.Login; import org.apache.hugegraph.structure.auth.LoginResult; import org.apache.hugegraph.structure.constant.HugeType; public class LoginAPI extends AuthAPI { - public LoginAPI(RestClient client, String graph) { + public LoginAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -35,7 +35,7 @@ protected String type() { } public LoginResult login(Login login) { - RestResult result = this.client.post(this.path(), login); + OkhttpRestResult result = this.client.post(this.path(), login); return result.readObject(LoginResult.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LogoutAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LogoutAPI.java index c26c5af91..ad6c3980f 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LogoutAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LogoutAPI.java @@ -17,14 +17,14 @@ package org.apache.hugegraph.api.auth; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.structure.constant.HugeType; import com.google.common.collect.ImmutableMap; public class LogoutAPI extends AuthAPI { - public LogoutAPI(RestClient client, String graph) { + public LogoutAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/ProjectAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/ProjectAPI.java index dbf9248f7..d23529af6 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/ProjectAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/ProjectAPI.java @@ -21,8 +21,8 @@ import java.util.Map; import java.util.Set; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.auth.Project; import org.apache.hugegraph.structure.constant.HugeType; @@ -33,7 +33,7 @@ public class ProjectAPI extends AuthAPI { private static final String ACTION_ADD_GRAPH = "add_graph"; private static final String ACTION_REMOVE_GRAPH = "remove_graph"; - public ProjectAPI(RestClient client, String graph) { + public ProjectAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -43,25 +43,25 @@ protected String type() { } public Project create(Project project) { - RestResult result = this.client.post(this.path(), project); + OkhttpRestResult result = this.client.post(this.path(), project); return result.readObject(Project.class); } public Project get(Object id) { - RestResult result = this.client.get(this.path(), formatEntityId(id)); + OkhttpRestResult result = this.client.get(this.path(), formatEntityId(id)); return result.readObject(Project.class); } public List list(long limit) { checkLimit(limit, "Limit"); Map params = ImmutableMap.of("limit", limit); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Project.class); } public Project update(Project project) { String id = formatEntityId(project.id()); - RestResult result = this.client.put(this.path(), id, project); + OkhttpRestResult result = this.client.put(this.path(), id, project); return result.readObject(Project.class); } @@ -72,7 +72,7 @@ public void delete(Object id) { public Project addGraphs(Object projectId, Set graphs) { Project project = new Project(); project.graphs(graphs); - RestResult result = this.client.put(this.path(), + OkhttpRestResult result = this.client.put(this.path(), formatEntityId(projectId), project, ImmutableMap.of("action", @@ -83,7 +83,7 @@ public Project addGraphs(Object projectId, Set graphs) { public Project removeGraphs(Object projectId, Set graphs) { Project project = new Project(); project.graphs(graphs); - RestResult result = this.client.put(this.path(), + OkhttpRestResult result = this.client.put(this.path(), formatEntityId(projectId), project, ImmutableMap.of("action", diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TargetAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TargetAPI.java index 2e3687d96..371a15183 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TargetAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TargetAPI.java @@ -20,8 +20,8 @@ import java.util.List; import java.util.Map; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.auth.Target; import org.apache.hugegraph.structure.constant.HugeType; @@ -29,7 +29,7 @@ public class TargetAPI extends AuthAPI { - public TargetAPI(RestClient client, String graph) { + public TargetAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -39,25 +39,25 @@ protected String type() { } public Target create(Target target) { - RestResult result = this.client.post(this.path(), target); + OkhttpRestResult result = this.client.post(this.path(), target); return result.readObject(Target.class); } public Target get(Object id) { - RestResult result = this.client.get(this.path(), formatEntityId(id)); + OkhttpRestResult result = this.client.get(this.path(), formatEntityId(id)); return result.readObject(Target.class); } public List list(int limit) { checkLimit(limit, "Limit"); Map params = ImmutableMap.of("limit", limit); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Target.class); } public Target update(Target target) { String id = formatEntityId(target.id()); - RestResult result = this.client.put(this.path(), id, target); + OkhttpRestResult result = this.client.put(this.path(), id, target); return result.readObject(Target.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TokenAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TokenAPI.java index 58b3b73a1..032a18920 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TokenAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TokenAPI.java @@ -17,14 +17,14 @@ package org.apache.hugegraph.api.auth; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.auth.TokenPayload; import org.apache.hugegraph.structure.constant.HugeType; public class TokenAPI extends AuthAPI { - public TokenAPI(RestClient client, String graph) { + public TokenAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -34,7 +34,7 @@ protected String type() { } public TokenPayload verifyToken() { - RestResult result = this.client.get(this.path()); + OkhttpRestResult result = this.client.get(this.path()); return result.readObject(TokenPayload.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java index 5b1ea3254..e0b6eed4e 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java @@ -20,8 +20,8 @@ import java.util.List; import java.util.Map; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.auth.User; import org.apache.hugegraph.structure.auth.User.UserRole; import org.apache.hugegraph.structure.constant.HugeType; @@ -30,7 +30,7 @@ public class UserAPI extends AuthAPI { - public UserAPI(RestClient client, String graph) { + public UserAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -40,12 +40,12 @@ protected String type() { } public User create(User user) { - RestResult result = this.client.post(this.path(), user); + OkhttpRestResult result = this.client.post(this.path(), user); return result.readObject(User.class); } public User get(Object id) { - RestResult result = this.client.get(this.path(), formatEntityId(id)); + OkhttpRestResult result = this.client.get(this.path(), formatEntityId(id)); return result.readObject(User.class); } @@ -53,20 +53,20 @@ public UserRole getUserRole(Object id) { // String idEncoded = RestClient.encode(formatEntityId(id)); String idEncoded = formatEntityId(id); String path = String.join("/", this.path(), idEncoded, "role"); - RestResult result = this.client.get(path); + OkhttpRestResult result = this.client.get(path); return result.readObject(UserRole.class); } public List list(int limit) { checkLimit(limit, "Limit"); Map params = ImmutableMap.of("limit", limit); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(this.type(), User.class); } public User update(User user) { String id = formatEntityId(user.id()); - RestResult result = this.client.put(this.path(), id, user); + OkhttpRestResult result = this.client.put(this.path(), id, user); return result.readObject(User.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java index 99bcb669c..fd4860dce 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java @@ -22,9 +22,9 @@ import java.util.Map; import okhttp3.Headers; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.exception.NotAllCreatedException; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.graph.BatchEdgeRequest; @@ -35,7 +35,7 @@ public class EdgeAPI extends GraphAPI { - public EdgeAPI(RestClient client, String graph) { + public EdgeAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -45,7 +45,7 @@ protected String type() { } public Edge create(Edge edge) { - RestResult result = this.client.post(this.path(), edge); + OkhttpRestResult result = this.client.post(this.path(), edge); return result.readObject(Edge.class); } @@ -55,7 +55,7 @@ public List create(List edges, boolean checkVertex) { Headers headers = new Headers.Builder().add("Content-Encoding", BATCH_ENCODING).build(); Map params = ImmutableMap.of("check_vertex", checkVertex); - RestResult result = this.client.post(this.batchPath(), edges, + OkhttpRestResult result = this.client.post(this.batchPath(), edges, headers, params); List ids = result.readList(String.class); if (edges.size() != ids.size()) { @@ -71,7 +71,7 @@ public List update(BatchEdgeRequest request) { // MultivaluedHashMap headers = new MultivaluedHashMap<>(); // headers.putSingle("Content-Encoding", BATCH_ENCODING); Headers headers = new Headers.Builder().add("Content-Encoding", BATCH_ENCODING).build(); - RestResult result = this.client.put(this.batchPath(), null, + OkhttpRestResult result = this.client.put(this.batchPath(), null, request, headers); return result.readList(this.type(), Edge.class); } @@ -79,19 +79,19 @@ public List update(BatchEdgeRequest request) { public Edge append(Edge edge) { String id = edge.id(); Map params = ImmutableMap.of("action", "append"); - RestResult result = this.client.put(this.path(), id, edge, params); + OkhttpRestResult result = this.client.put(this.path(), id, edge, params); return result.readObject(Edge.class); } public Edge eliminate(Edge edge) { String id = edge.id(); Map params = ImmutableMap.of("action", "eliminate"); - RestResult result = this.client.put(this.path(), id, edge, params); + OkhttpRestResult result = this.client.put(this.path(), id, edge, params); return result.readObject(Edge.class); } public Edge get(String id) { - RestResult result = this.client.get(this.path(), id); + OkhttpRestResult result = this.client.get(this.path(), id); return result.readObject(Edge.class); } @@ -122,7 +122,7 @@ public Edges list(Object vertexId, Direction direction, String label, params.put("offset", offset); params.put("limit", limit); params.put("page", page); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readObject(Edges.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java index d76929dc2..3767eb782 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java @@ -21,7 +21,7 @@ import java.util.UUID; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.util.E; import org.apache.hugegraph.util.JsonUtil; @@ -31,7 +31,7 @@ public abstract class GraphAPI extends API { private final String batchPath; - public GraphAPI(RestClient client, String graph) { + public GraphAPI(OkhttpOkhttpRestClient client, String graph) { super(client); this.path(PATH, graph, this.type()); this.batchPath = String.join("/", this.path(), "batch"); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java index 6c8391a80..b02022141 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java @@ -19,10 +19,10 @@ import com.google.common.collect.ImmutableMap; import okhttp3.Headers; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.exception.InvalidResponseException; import org.apache.hugegraph.exception.NotAllCreatedException; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.graph.BatchOlapPropertyRequest; import org.apache.hugegraph.structure.graph.BatchVertexRequest; @@ -35,7 +35,7 @@ public class VertexAPI extends GraphAPI { - public VertexAPI(RestClient client, String graph) { + public VertexAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -45,7 +45,7 @@ protected String type() { } public Vertex create(Vertex vertex) { - RestResult result = this.client.post(this.path(), vertex); + OkhttpRestResult result = this.client.post(this.path(), vertex); return result.readObject(Vertex.class); } @@ -53,7 +53,7 @@ public List create(List vertices) { // MultivaluedHashMap headers = new MultivaluedHashMap<>(); // headers.putSingle("Content-Encoding", BATCH_ENCODING); Headers headers = new Headers.Builder().add("Content-Encoding", BATCH_ENCODING).build(); - RestResult result = this.client.post(this.batchPath(), vertices, + OkhttpRestResult result = this.client.post(this.batchPath(), vertices, headers); List ids = result.readList(Object.class); if (vertices.size() != ids.size()) { @@ -69,7 +69,7 @@ public List update(BatchVertexRequest request) { // MultivaluedHashMap headers = new MultivaluedHashMap<>(); // headers.putSingle("Content-Encoding", BATCH_ENCODING); Headers headers = new Headers.Builder().add("Content-Encoding", BATCH_ENCODING).build(); - RestResult result = this.client.put(this.batchPath(), null, + OkhttpRestResult result = this.client.put(this.batchPath(), null, request, headers); return result.readList(this.type(), Vertex.class); } @@ -80,7 +80,7 @@ public int update(BatchOlapPropertyRequest request) { // headers.putSingle("Content-Encoding", BATCH_ENCODING); Headers headers = new Headers.Builder().add("Content-Encoding", BATCH_ENCODING).build(); String path = String.join("/", this.path(), "olap/batch"); - RestResult result = this.client.put(path, null, request, headers); + OkhttpRestResult result = this.client.put(path, null, request, headers); Object size = result.readObject(Map.class).get("size"); if (!(size instanceof Integer)) { throw new InvalidResponseException("The 'size' in response must be int, " + @@ -92,20 +92,20 @@ public int update(BatchOlapPropertyRequest request) { public Vertex append(Vertex vertex) { String id = formatVertexId(vertex.id()); Map params = ImmutableMap.of("action", "append"); - RestResult result = this.client.put(this.path(), id, vertex, params); + OkhttpRestResult result = this.client.put(this.path(), id, vertex, params); return result.readObject(Vertex.class); } public Vertex eliminate(Vertex vertex) { String id = formatVertexId(vertex.id()); Map params = ImmutableMap.of("action", "eliminate"); - RestResult result = this.client.put(this.path(), id, vertex, params); + OkhttpRestResult result = this.client.put(this.path(), id, vertex, params); return result.readObject(Vertex.class); } public Vertex get(Object id) { String vertexId = formatVertexId(id); - RestResult result = this.client.get(this.path(), vertexId); + OkhttpRestResult result = this.client.get(this.path(), vertexId); return result.readObject(Vertex.class); } @@ -130,7 +130,7 @@ public Vertices list(String label, Map properties, params.put("offset", offset); params.put("limit", limit); params.put("page", page); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readObject(Vertices.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java index 19b073633..902457347 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java @@ -21,9 +21,9 @@ import okhttp3.Headers; import org.apache.commons.lang3.StringUtils; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.exception.InvalidResponseException; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.GraphMode; import org.apache.hugegraph.structure.constant.GraphReadMode; import org.apache.hugegraph.structure.constant.HugeType; @@ -40,7 +40,7 @@ public class GraphsAPI extends API { private static final String CONFIRM_MESSAGE = "confirm_message"; - public GraphsAPI(RestClient client) { + public GraphsAPI(OkhttpOkhttpRestClient client) { super(client); this.path(this.type()); } @@ -61,19 +61,19 @@ public Map create(String name, String cloneGraphName, if (StringUtils.isNotEmpty(cloneGraphName)) { params = ImmutableMap.of("clone_graph_name", cloneGraphName); } - RestResult result = this.client.post(joinPath(this.path(), name), + OkhttpRestResult result = this.client.post(joinPath(this.path(), name), configText, headers, params); return result.readObject(Map.class); } @SuppressWarnings("unchecked") public Map get(String name) { - RestResult result = this.client.get(this.path(), name); + OkhttpRestResult result = this.client.get(this.path(), name); return result.readObject(Map.class); } public List list() { - RestResult result = this.client.get(this.path()); + OkhttpRestResult result = this.client.get(this.path()); return result.readList(this.type(), String.class); } @@ -95,7 +95,7 @@ public void mode(String graph, GraphMode mode) { } public GraphMode mode(String graph) { - RestResult result = this.client.get(joinPath(this.path(), graph), MODE); + OkhttpRestResult result = this.client.get(joinPath(this.path(), graph), MODE); @SuppressWarnings("unchecked") Map mode = result.readObject(Map.class); String value = mode.get(MODE); @@ -120,7 +120,7 @@ public void readMode(String graph, GraphReadMode readMode) { public GraphReadMode readMode(String graph) { this.client.checkApiVersion("0.59", "graph read mode"); - RestResult result = this.client.get(joinPath(this.path(), graph), + OkhttpRestResult result = this.client.get(joinPath(this.path(), graph), GRAPH_READ_MODE); @SuppressWarnings("unchecked") Map readMode = result.readObject(Map.class); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/CypherAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/CypherAPI.java index 63cf438b9..6353375c4 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/CypherAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/CypherAPI.java @@ -18,8 +18,8 @@ package org.apache.hugegraph.api.gremlin; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.gremlin.Response; @@ -27,7 +27,7 @@ public class CypherAPI extends API { private static final String PATH = "graphs/%s/cypher"; - public CypherAPI(RestClient client, String graph) { + public CypherAPI(OkhttpOkhttpRestClient client, String graph) { super(client); this.path(PATH, graph); } @@ -38,7 +38,7 @@ protected String type() { } public Response post(String cypher) { - RestResult result = this.client.post(this.path(), cypher); + OkhttpRestResult result = this.client.post(this.path(), cypher); return result.readObject(Response.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/GremlinAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/GremlinAPI.java index 31795d193..d5dbfdf6a 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/GremlinAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/GremlinAPI.java @@ -18,14 +18,14 @@ package org.apache.hugegraph.api.gremlin; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.gremlin.Response; public class GremlinAPI extends API { - public GremlinAPI(RestClient client) { + public GremlinAPI(OkhttpOkhttpRestClient client) { super(client); this.path(type()); } @@ -36,7 +36,7 @@ protected String type() { } public Response post(GremlinRequest request) { - RestResult result = this.client.post(this.path(), request); + OkhttpRestResult result = this.client.post(this.path(), request); return result.readObject(Response.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/GremlinJobAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/GremlinJobAPI.java index 36bb720be..040bd1b1f 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/GremlinJobAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/GremlinJobAPI.java @@ -21,14 +21,14 @@ import org.apache.hugegraph.api.gremlin.GremlinRequest; import org.apache.hugegraph.api.task.TaskAPI; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; public class GremlinJobAPI extends JobAPI { private static final String JOB_TYPE = "gremlin"; - public GremlinJobAPI(RestClient client, String graph) { + public GremlinJobAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -38,7 +38,7 @@ protected String jobType() { } public long execute(GremlinRequest request) { - RestResult result = this.client.post(this.path(), request); + OkhttpRestResult result = this.client.post(this.path(), request); @SuppressWarnings("unchecked") Map task = result.readObject(Map.class); return TaskAPI.parseTaskId(task); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/JobAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/JobAPI.java index da2300acb..0e64c439d 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/JobAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/JobAPI.java @@ -18,7 +18,7 @@ package org.apache.hugegraph.api.job; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.structure.constant.HugeType; public abstract class JobAPI extends API { @@ -26,7 +26,7 @@ public abstract class JobAPI extends API { // For example: graphs/hugegraph/jobs/gremlin private static final String PATH = "graphs/%s/%s/%s"; - public JobAPI(RestClient client, String graph) { + public JobAPI(OkhttpOkhttpRestClient client, String graph) { super(client); this.path(String.format(PATH, graph, this.type(), this.jobType())); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/RebuildAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/RebuildAPI.java index d3ea915b0..ba20798ed 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/RebuildAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/RebuildAPI.java @@ -20,8 +20,8 @@ import java.util.Map; import org.apache.hugegraph.api.task.TaskAPI; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.SchemaElement; import org.apache.hugegraph.structure.schema.EdgeLabel; import org.apache.hugegraph.structure.schema.IndexLabel; @@ -32,7 +32,7 @@ public class RebuildAPI extends JobAPI { private static final String JOB_TYPE = "rebuild"; - public RebuildAPI(RestClient client, String graph) { + public RebuildAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -60,7 +60,7 @@ private long rebuildIndex(SchemaElement element) { "Only VertexLabel, EdgeLabel and IndexLabel support " + "rebuild, but got '%s'", element); String path = String.join(PATH_SPLITOR, this.path(), element.type()); - RestResult result = this.client.put(path, element.name(), element); + OkhttpRestResult result = this.client.put(path, element.name(), element); @SuppressWarnings("unchecked") Map task = result.readObject(Map.class); return TaskAPI.parseTaskId(task); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java index a4fd226df..0e619aadd 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java @@ -21,13 +21,13 @@ import org.apache.hugegraph.util.CommonUtil; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.HugeType; public class MetricsAPI extends API { - public MetricsAPI(RestClient client) { + public MetricsAPI(OkhttpOkhttpRestClient client) { super(client); this.path(this.type()); } @@ -39,7 +39,7 @@ protected String type() { @SuppressWarnings("unchecked") public Map> system() { - RestResult result = this.client.get(this.path(), "system"); + OkhttpRestResult result = this.client.get(this.path(), "system"); Map map = result.readObject(Map.class); CommonUtil.checkMapClass(map, String.class, Map.class); for (Object mapValue : map.values()) { @@ -50,7 +50,7 @@ public Map> system() { @SuppressWarnings("unchecked") public Map> backend() { - RestResult result = this.client.get(this.path(), "backend"); + OkhttpRestResult result = this.client.get(this.path(), "backend"); Map map = result.readObject(Map.class); CommonUtil.checkMapClass(map, String.class, Map.class); for (Object mapValue : map.values()) { @@ -65,7 +65,7 @@ public Map backend(String graph) { @SuppressWarnings("unchecked") public Map> all() { - RestResult result = this.client.get(this.path()); + OkhttpRestResult result = this.client.get(this.path()); Map map = result.readObject(Map.class); CommonUtil.checkMapClass(map, String.class, Map.class); for (Object mapValue : map.values()) { diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/EdgeLabelAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/EdgeLabelAPI.java index 08efe67a4..f74ec058a 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/EdgeLabelAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/EdgeLabelAPI.java @@ -21,8 +21,8 @@ import java.util.Map; import org.apache.hugegraph.api.task.TaskAPI; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.SchemaElement; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.schema.EdgeLabel; @@ -32,7 +32,7 @@ public class EdgeLabelAPI extends SchemaElementAPI { - public EdgeLabelAPI(RestClient client, String graph) { + public EdgeLabelAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -43,7 +43,7 @@ protected String type() { public EdgeLabel create(EdgeLabel edgeLabel) { Object el = this.checkCreateOrUpdate(edgeLabel); - RestResult result = this.client.post(this.path(), el); + OkhttpRestResult result = this.client.post(this.path(), el); return result.readObject(EdgeLabel.class); } @@ -51,7 +51,7 @@ public EdgeLabel append(EdgeLabel edgeLabel) { String id = edgeLabel.name(); Map params = ImmutableMap.of("action", "append"); Object el = this.checkCreateOrUpdate(edgeLabel); - RestResult result = this.client.put(this.path(), id, el, params); + OkhttpRestResult result = this.client.put(this.path(), id, el, params); return result.readObject(EdgeLabel.class); } @@ -59,17 +59,17 @@ public EdgeLabel eliminate(EdgeLabel edgeLabel) { String id = edgeLabel.name(); Map params = ImmutableMap.of("action", "eliminate"); Object el = this.checkCreateOrUpdate(edgeLabel); - RestResult result = this.client.put(this.path(), id, el, params); + OkhttpRestResult result = this.client.put(this.path(), id, el, params); return result.readObject(EdgeLabel.class); } public EdgeLabel get(String name) { - RestResult result = this.client.get(this.path(), name); + OkhttpRestResult result = this.client.get(this.path(), name); return result.readObject(EdgeLabel.class); } public List list() { - RestResult result = this.client.get(this.path()); + OkhttpRestResult result = this.client.get(this.path()); return result.readList(this.type(), EdgeLabel.class); } @@ -78,12 +78,12 @@ public List list(List names) { E.checkArgument(names != null && !names.isEmpty(), "The edge label names can't be null or empty"); Map params = ImmutableMap.of("names", names); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(this.type(), EdgeLabel.class); } public long delete(String name) { - RestResult result = this.client.delete(this.path(), name); + OkhttpRestResult result = this.client.delete(this.path(), name); @SuppressWarnings("unchecked") Map task = result.readObject(Map.class); return TaskAPI.parseTaskId(task); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/IndexLabelAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/IndexLabelAPI.java index aa8d08b79..e301cd9bd 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/IndexLabelAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/IndexLabelAPI.java @@ -21,9 +21,9 @@ import java.util.Map; import org.apache.hugegraph.api.task.TaskAPI; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.exception.NotSupportException; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.SchemaElement; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.constant.IndexType; @@ -34,7 +34,7 @@ public class IndexLabelAPI extends SchemaElementAPI { - public IndexLabelAPI(RestClient client, String graph) { + public IndexLabelAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -45,7 +45,7 @@ protected String type() { public IndexLabel.IndexLabelWithTask create(IndexLabel indexLabel) { Object il = this.checkCreateOrUpdate(indexLabel); - RestResult result = this.client.post(this.path(), il); + OkhttpRestResult result = this.client.post(this.path(), il); return result.readObject(IndexLabel.IndexLabelWithTask.class); } @@ -57,7 +57,7 @@ public IndexLabel append(IndexLabel indexLabel) { String id = indexLabel.name(); Map params = ImmutableMap.of("action", "append"); Object il = this.checkCreateOrUpdate(indexLabel); - RestResult result = this.client.put(this.path(), id, il, params); + OkhttpRestResult result = this.client.put(this.path(), id, il, params); return result.readObject(IndexLabel.class); } @@ -69,17 +69,17 @@ public IndexLabel eliminate(IndexLabel indexLabel) { String id = indexLabel.name(); Map params = ImmutableMap.of("action", "eliminate"); Object il = this.checkCreateOrUpdate(indexLabel); - RestResult result = this.client.put(this.path(), id, il, params); + OkhttpRestResult result = this.client.put(this.path(), id, il, params); return result.readObject(IndexLabel.class); } public IndexLabel get(String name) { - RestResult result = this.client.get(this.path(), name); + OkhttpRestResult result = this.client.get(this.path(), name); return result.readObject(IndexLabel.class); } public List list() { - RestResult result = this.client.get(this.path()); + OkhttpRestResult result = this.client.get(this.path()); return result.readList(this.type(), IndexLabel.class); } @@ -88,12 +88,12 @@ public List list(List names) { E.checkArgument(names != null && !names.isEmpty(), "The index label names can't be null or empty"); Map params = ImmutableMap.of("names", names); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(this.type(), IndexLabel.class); } public long delete(String name) { - RestResult result = this.client.delete(this.path(), name); + OkhttpRestResult result = this.client.delete(this.path(), name); @SuppressWarnings("unchecked") Map task = result.readObject(Map.class); return TaskAPI.parseTaskId(task); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/PropertyKeyAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/PropertyKeyAPI.java index 11b3546bd..34cb5bca8 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/PropertyKeyAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/PropertyKeyAPI.java @@ -21,9 +21,9 @@ import java.util.Map; import org.apache.hugegraph.api.task.TaskAPI; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.exception.NotSupportException; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.SchemaElement; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.constant.WriteType; @@ -34,7 +34,7 @@ public class PropertyKeyAPI extends SchemaElementAPI { - public PropertyKeyAPI(RestClient client, String graph) { + public PropertyKeyAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -45,7 +45,7 @@ protected String type() { public PropertyKey.PropertyKeyWithTask create(PropertyKey propertyKey) { Object pkey = this.checkCreateOrUpdate(propertyKey); - RestResult result = this.client.post(this.path(), pkey); + OkhttpRestResult result = this.client.post(this.path(), pkey); if (this.client.apiVersionLt("0.65")) { return new PropertyKey.PropertyKeyWithTask(result.readObject(PropertyKey.class), 0L); } @@ -56,7 +56,7 @@ public PropertyKey.PropertyKeyWithTask append(PropertyKey propertyKey) { String id = propertyKey.name(); Map params = ImmutableMap.of("action", "append"); Object pkey = this.checkCreateOrUpdate(propertyKey); - RestResult result = this.client.put(this.path(), id, pkey, params); + OkhttpRestResult result = this.client.put(this.path(), id, pkey, params); return result.readObject(PropertyKey.PropertyKeyWithTask.class); } @@ -64,7 +64,7 @@ public PropertyKey.PropertyKeyWithTask eliminate(PropertyKey propertyKey) { String id = propertyKey.name(); Map params = ImmutableMap.of("action", "eliminate"); Object pkey = this.checkCreateOrUpdate(propertyKey); - RestResult result = this.client.put(this.path(), id, pkey, params); + OkhttpRestResult result = this.client.put(this.path(), id, pkey, params); return result.readObject(PropertyKey.PropertyKeyWithTask.class); } @@ -75,17 +75,17 @@ public PropertyKey.PropertyKeyWithTask clear(PropertyKey propertyKey) { String id = propertyKey.name(); Map params = ImmutableMap.of("action", "clear"); Object pkey = this.checkCreateOrUpdate(propertyKey); - RestResult result = this.client.put(this.path(), id, pkey, params); + OkhttpRestResult result = this.client.put(this.path(), id, pkey, params); return result.readObject(PropertyKey.PropertyKeyWithTask.class); } public PropertyKey get(String name) { - RestResult result = this.client.get(this.path(), name); + OkhttpRestResult result = this.client.get(this.path(), name); return result.readObject(PropertyKey.class); } public List list() { - RestResult result = this.client.get(this.path()); + OkhttpRestResult result = this.client.get(this.path()); return result.readList(this.type(), PropertyKey.class); } @@ -94,7 +94,7 @@ public List list(List names) { E.checkArgument(names != null && !names.isEmpty(), "The property key names can't be null or empty"); Map params = ImmutableMap.of("names", names); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(this.type(), PropertyKey.class); } @@ -103,7 +103,7 @@ public long delete(String name) { this.client.delete(this.path(), name); return 0L; } - RestResult result = this.client.delete(this.path(), name); + OkhttpRestResult result = this.client.delete(this.path(), name); @SuppressWarnings("unchecked") Map task = result.readObject(Map.class); return TaskAPI.parseTaskId(task); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaAPI.java index 5b114aa3b..84e67e278 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaAPI.java @@ -21,16 +21,16 @@ import java.util.Map; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.exception.NotSupportException; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.SchemaElement; public class SchemaAPI extends API { private static final String PATH = "graphs/%s/%s"; - public SchemaAPI(RestClient client, String graph) { + public SchemaAPI(OkhttpOkhttpRestClient client, String graph) { super(client); this.path(PATH, graph, this.type()); } @@ -40,7 +40,7 @@ public Map> list() { if (this.client.apiVersionLt("0.66")) { throw new NotSupportException("schema get api"); } - RestResult result = this.client.get(this.path()); + OkhttpRestResult result = this.client.get(this.path()); return result.readObject(Map.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaElementAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaElementAPI.java index 417294476..781d9d52c 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaElementAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaElementAPI.java @@ -18,14 +18,14 @@ package org.apache.hugegraph.api.schema; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.structure.SchemaElement; public abstract class SchemaElementAPI extends API { private static final String PATH = "graphs/%s/schema/%s"; - public SchemaElementAPI(RestClient client, String graph) { + public SchemaElementAPI(OkhttpOkhttpRestClient client, String graph) { super(client); this.path(PATH, graph, this.type()); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/VertexLabelAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/VertexLabelAPI.java index 79d2477ca..12fa90210 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/VertexLabelAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/VertexLabelAPI.java @@ -21,8 +21,8 @@ import java.util.Map; import org.apache.hugegraph.api.task.TaskAPI; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.SchemaElement; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.schema.VertexLabel; @@ -32,7 +32,7 @@ public class VertexLabelAPI extends SchemaElementAPI { - public VertexLabelAPI(RestClient client, String graph) { + public VertexLabelAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -43,7 +43,7 @@ protected String type() { public VertexLabel create(VertexLabel vertexLabel) { Object vl = this.checkCreateOrUpdate(vertexLabel); - RestResult result = this.client.post(this.path(), vl); + OkhttpRestResult result = this.client.post(this.path(), vl); return result.readObject(VertexLabel.class); } @@ -51,7 +51,7 @@ public VertexLabel append(VertexLabel vertexLabel) { String id = vertexLabel.name(); Map params = ImmutableMap.of("action", "append"); Object vl = this.checkCreateOrUpdate(vertexLabel); - RestResult result = this.client.put(this.path(), id, vl, params); + OkhttpRestResult result = this.client.put(this.path(), id, vl, params); return result.readObject(VertexLabel.class); } @@ -59,17 +59,17 @@ public VertexLabel eliminate(VertexLabel vertexLabel) { String id = vertexLabel.name(); Map params = ImmutableMap.of("action", "eliminate"); Object vl = this.checkCreateOrUpdate(vertexLabel); - RestResult result = this.client.put(this.path(), id, vl, params); + OkhttpRestResult result = this.client.put(this.path(), id, vl, params); return result.readObject(VertexLabel.class); } public VertexLabel get(String name) { - RestResult result = this.client.get(this.path(), name); + OkhttpRestResult result = this.client.get(this.path(), name); return result.readObject(VertexLabel.class); } public List list() { - RestResult result = this.client.get(this.path()); + OkhttpRestResult result = this.client.get(this.path()); return result.readList(this.type(), VertexLabel.class); } @@ -78,12 +78,12 @@ public List list(List names) { E.checkArgument(names != null && !names.isEmpty(), "The vertex label names can't be null or empty"); Map params = ImmutableMap.of("names", names); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(this.type(), VertexLabel.class); } public long delete(String name) { - RestResult result = this.client.delete(this.path(), name); + OkhttpRestResult result = this.client.delete(this.path(), name); @SuppressWarnings("unchecked") Map task = result.readObject(Map.class); return TaskAPI.parseTaskId(task); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/task/TaskAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/task/TaskAPI.java index b348ef017..b338d5c70 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/task/TaskAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/task/TaskAPI.java @@ -23,9 +23,9 @@ import org.apache.hugegraph.util.TaskCache; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.rest.ClientException; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.Task; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.util.E; @@ -41,7 +41,7 @@ public class TaskAPI extends API { public static final long TASK_TIMEOUT = 60L; private static final long QUERY_INTERVAL = 500L; - public TaskAPI(RestClient client, String graph) { + public TaskAPI(OkhttpOkhttpRestClient client, String graph) { super(client); this.path(String.format(PATH, graph)); this.graph = graph; @@ -62,7 +62,7 @@ public List list(String status, long limit) { if (status != null) { params.put("status", status); } - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(TASKS, Task.class); } @@ -75,19 +75,19 @@ public TasksWithPage list(String status, String page, long limit) { if (status != null) { params.put("status", status); } - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readObject(TasksWithPage.class); } public List list(List ids) { Map params = new LinkedHashMap<>(); params.put("ids", ids); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(TASKS, Task.class); } public Task get(long id) { - RestResult result = this.client.get(this.path(), String.valueOf(id)); + OkhttpRestResult result = this.client.get(this.path(), String.valueOf(id)); return result.readObject(Task.class); } @@ -97,7 +97,7 @@ public void delete(long id) { public Task cancel(long id) { Map params = ImmutableMap.of("action", "cancel"); - RestResult result = this.client.put(path(), String.valueOf(id), + OkhttpRestResult result = this.client.put(path(), String.valueOf(id), ImmutableMap.of(), params); return result.readObject(Task.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/AllShortestPathsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/AllShortestPathsAPI.java index d692935f7..ff99b22cc 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/AllShortestPathsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/AllShortestPathsAPI.java @@ -22,14 +22,14 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; public class AllShortestPathsAPI extends TraversersAPI { - public AllShortestPathsAPI(RestClient client, String graph) { + public AllShortestPathsAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -59,7 +59,7 @@ public List get(Object sourceId, Object targetId, params.put("max_degree", degree); params.put("skip_degree", skipDegree); params.put("capacity", capacity); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList("paths", Path.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CountAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CountAPI.java index 788e38797..5d9e4bf92 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CountAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CountAPI.java @@ -19,8 +19,8 @@ import java.util.Map; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.traverser.CountRequest; import org.apache.hugegraph.util.E; @@ -28,7 +28,7 @@ public class CountAPI extends TraversersAPI { private static final String COUNT = "count"; - public CountAPI(RestClient client, String graph) { + public CountAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -39,7 +39,7 @@ protected String type() { public long post(CountRequest request) { this.client.checkApiVersion("0.55", "count"); - RestResult result = this.client.post(this.path(), request); + OkhttpRestResult result = this.client.post(this.path(), request); @SuppressWarnings("unchecked") Map countMap = result.readObject(Map.class); E.checkState(countMap.containsKey(COUNT), diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CrosspointsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CrosspointsAPI.java index 196691013..c5c9e7185 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CrosspointsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CrosspointsAPI.java @@ -22,14 +22,14 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; public class CrosspointsAPI extends TraversersAPI { - public CrosspointsAPI(RestClient client, String graph) { + public CrosspointsAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -59,7 +59,7 @@ public List get(Object sourceId, Object targetId, params.put("max_degree", degree); params.put("capacity", capacity); params.put("limit", limit); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList("crosspoints", Path.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedCrosspointsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedCrosspointsAPI.java index 70eb94819..39bbe9f96 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedCrosspointsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedCrosspointsAPI.java @@ -17,14 +17,14 @@ package org.apache.hugegraph.api.traverser; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.traverser.CrosspointsRequest; import org.apache.hugegraph.structure.traverser.CustomizedCrosspoints; public class CustomizedCrosspointsAPI extends TraversersAPI { - public CustomizedCrosspointsAPI(RestClient client, String graph) { + public CustomizedCrosspointsAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -34,7 +34,7 @@ protected String type() { } public CustomizedCrosspoints post(CrosspointsRequest request) { - RestResult result = this.client.post(this.path(), request); + OkhttpRestResult result = this.client.post(this.path(), request); return result.readObject(CustomizedCrosspoints.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedPathsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedPathsAPI.java index 43a826f67..115991e7b 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedPathsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedPathsAPI.java @@ -17,14 +17,14 @@ package org.apache.hugegraph.api.traverser; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.traverser.PathsWithVertices; import org.apache.hugegraph.structure.traverser.CustomizedPathsRequest; public class CustomizedPathsAPI extends TraversersAPI { - public CustomizedPathsAPI(RestClient client, String graph) { + public CustomizedPathsAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -34,7 +34,7 @@ protected String type() { } public PathsWithVertices post(CustomizedPathsRequest request) { - RestResult result = this.client.post(this.path(), request); + OkhttpRestResult result = this.client.post(this.path(), request); return result.readObject(PathsWithVertices.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/EdgesAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/EdgesAPI.java index 162b9dec9..d0d828294 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/EdgesAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/EdgesAPI.java @@ -21,8 +21,8 @@ import java.util.List; import java.util.Map; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.graph.Edge; import org.apache.hugegraph.structure.graph.Edges; import org.apache.hugegraph.structure.graph.Shard; @@ -32,7 +32,7 @@ public class EdgesAPI extends TraversersAPI { - public EdgesAPI(RestClient client, String graph) { + public EdgesAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -47,14 +47,14 @@ public List list(List ids) { Map params = new LinkedHashMap<>(); params.put("ids", ids); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Edge.class); } public List shards(long splitSize) { String path = String.join(PATH_SPLITOR, this.path(), "shards"); Map params = ImmutableMap.of("split_size", splitSize); - RestResult result = this.client.get(path, params); + OkhttpRestResult result = this.client.get(path, params); return result.readList("shards", Shard.class); } @@ -66,7 +66,7 @@ public Edges scan(Shard shard, String page, long pageLimit) { params.put("end", shard.end()); params.put("page", page); params.put("page_limit", pageLimit); - RestResult result = this.client.get(path, params); + OkhttpRestResult result = this.client.get(path, params); return result.readObject(Edges.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/FusiformSimilarityAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/FusiformSimilarityAPI.java index 5987f0c60..b249b65ad 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/FusiformSimilarityAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/FusiformSimilarityAPI.java @@ -17,14 +17,14 @@ package org.apache.hugegraph.api.traverser; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.traverser.FusiformSimilarity; import org.apache.hugegraph.structure.traverser.FusiformSimilarityRequest; public class FusiformSimilarityAPI extends TraversersAPI { - public FusiformSimilarityAPI(RestClient client, String graph) { + public FusiformSimilarityAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -35,7 +35,7 @@ protected String type() { public FusiformSimilarity post(FusiformSimilarityRequest request) { this.client.checkApiVersion("0.49", "fusiform similarity"); - RestResult result = this.client.post(this.path(), request); + OkhttpRestResult result = this.client.post(this.path(), request); return result.readObject(FusiformSimilarity.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java index 41a827aea..ba4d8f54a 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java @@ -21,9 +21,9 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.traverser.SingleSourceJaccardSimilarityRequest; @@ -35,7 +35,7 @@ public class JaccardSimilarityAPI extends TraversersAPI { private static final String JACCARD_SIMILARITY = "jaccard_similarity"; - public JaccardSimilarityAPI(RestClient client, String graph) { + public JaccardSimilarityAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -56,7 +56,7 @@ public double get(Object vertexId, Object otherId, Direction direction, params.put("direction", direction); params.put("label", label); params.put("max_degree", degree); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); @SuppressWarnings("unchecked") Map jaccard = result.readObject(Map.class); E.checkState(jaccard.containsKey(JACCARD_SIMILARITY), @@ -67,7 +67,7 @@ public double get(Object vertexId, Object otherId, Direction direction, @SuppressWarnings("unchecked") public Map post(SingleSourceJaccardSimilarityRequest request) { this.client.checkApiVersion("0.58", "jaccard similar"); - RestResult result = this.client.post(this.path(), request); + OkhttpRestResult result = this.client.post(this.path(), request); return result.readObject(Map.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KneighborAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KneighborAPI.java index 7470e28c2..d8e66ff39 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KneighborAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KneighborAPI.java @@ -22,15 +22,15 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.traverser.Kneighbor; import org.apache.hugegraph.structure.traverser.KneighborRequest; public class KneighborAPI extends TraversersAPI { - public KneighborAPI(RestClient client, String graph) { + public KneighborAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -54,13 +54,13 @@ public List get(Object sourceId, Direction direction, params.put("max_depth", depth); params.put("max_degree", degree); params.put("limit", limit); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList("vertices", Object.class); } public Kneighbor post(KneighborRequest request) { this.client.checkApiVersion("0.58", "customized kneighbor"); - RestResult result = this.client.post(this.path(), request); + OkhttpRestResult result = this.client.post(this.path(), request); return result.readObject(Kneighbor.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KoutAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KoutAPI.java index ec9332715..757e8baa3 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KoutAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KoutAPI.java @@ -22,15 +22,15 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.traverser.Kout; import org.apache.hugegraph.structure.traverser.KoutRequest; public class KoutAPI extends TraversersAPI { - public KoutAPI(RestClient client, String graph) { + public KoutAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -58,13 +58,13 @@ public List get(Object sourceId, Direction direction, params.put("max_degree", degree); params.put("capacity", capacity); params.put("limit", limit); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList("vertices", Object.class); } public Kout post(KoutRequest request) { this.client.checkApiVersion("0.58", "customized kout"); - RestResult result = this.client.post(this.path(), request); + OkhttpRestResult result = this.client.post(this.path(), request); return result.readObject(Kout.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/MultiNodeShortestPathAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/MultiNodeShortestPathAPI.java index 8036d41c8..541b4c711 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/MultiNodeShortestPathAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/MultiNodeShortestPathAPI.java @@ -17,14 +17,14 @@ package org.apache.hugegraph.api.traverser; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.traverser.MultiNodeShortestPathRequest; import org.apache.hugegraph.structure.traverser.PathsWithVertices; public class MultiNodeShortestPathAPI extends TraversersAPI { - public MultiNodeShortestPathAPI(RestClient client, String graph) { + public MultiNodeShortestPathAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -35,7 +35,7 @@ protected String type() { public PathsWithVertices post(MultiNodeShortestPathRequest request) { this.client.checkApiVersion("0.58", "multi node shortest path"); - RestResult result = this.client.post(this.path(), request); + OkhttpRestResult result = this.client.post(this.path(), request); return result.readObject(PathsWithVertices.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/NeighborRankAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/NeighborRankAPI.java index d70573379..8019b2ad7 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/NeighborRankAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/NeighborRankAPI.java @@ -21,8 +21,8 @@ import java.util.Arrays; import java.util.List; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.constant.Traverser; import org.apache.hugegraph.structure.traverser.Ranks; @@ -32,7 +32,7 @@ public class NeighborRankAPI extends TraversersAPI { - public NeighborRankAPI(RestClient client, String graph) { + public NeighborRankAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -42,7 +42,7 @@ protected String type() { } public List post(Request request) { - RestResult result = this.client.post(this.path(), request); + OkhttpRestResult result = this.client.post(this.path(), request); return result.readList("ranks", Ranks.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PathsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PathsAPI.java index 2d14cae79..7cde5d152 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PathsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PathsAPI.java @@ -22,8 +22,8 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; import org.apache.hugegraph.structure.traverser.PathsRequest; @@ -31,7 +31,7 @@ public class PathsAPI extends TraversersAPI { - public PathsAPI(RestClient client, String graph) { + public PathsAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -61,13 +61,13 @@ public List get(Object sourceId, Object targetId, params.put("max_degree", degree); params.put("capacity", capacity); params.put("limit", limit); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList("paths", Path.class); } public PathsWithVertices post(PathsRequest request) { this.client.checkApiVersion("0.58", "paths with property filter"); - RestResult result = this.client.post(this.path(), request); + OkhttpRestResult result = this.client.post(this.path(), request); return result.readObject(PathsWithVertices.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PersonalRankAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PersonalRankAPI.java index 5d7fbb2b1..33e09823e 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PersonalRankAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PersonalRankAPI.java @@ -17,8 +17,8 @@ package org.apache.hugegraph.api.traverser; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Traverser; import org.apache.hugegraph.structure.traverser.Ranks; import org.apache.hugegraph.util.E; @@ -27,7 +27,7 @@ public class PersonalRankAPI extends TraversersAPI { - public PersonalRankAPI(RestClient client, String graph) { + public PersonalRankAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -37,7 +37,7 @@ protected String type() { } public Ranks post(Request request) { - RestResult result = this.client.post(this.path(), request); + OkhttpRestResult result = this.client.post(this.path(), request); return result.readObject(Ranks.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RaysAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RaysAPI.java index 9908b311b..3e1517dd7 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RaysAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RaysAPI.java @@ -22,14 +22,14 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; public class RaysAPI extends TraversersAPI { - public RaysAPI(RestClient client, String graph) { + public RaysAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -55,7 +55,7 @@ public List get(Object sourceId, Direction direction, String label, params.put("max_degree", degree); params.put("capacity", capacity); params.put("limit", limit); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Path.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RingsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RingsAPI.java index 26aaff444..b414ab2ac 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RingsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RingsAPI.java @@ -22,14 +22,14 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; public class RingsAPI extends TraversersAPI { - public RingsAPI(RestClient client, String graph) { + public RingsAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -62,7 +62,7 @@ public List get(Object sourceId, Direction direction, String label, params.put("max_degree", degree); params.put("capacity", capacity); params.put("limit", limit); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Path.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SameNeighborsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SameNeighborsAPI.java index 1ef4b9ce5..c24512d39 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SameNeighborsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SameNeighborsAPI.java @@ -22,15 +22,15 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; public class SameNeighborsAPI extends TraversersAPI { private static final String SAME_NEIGHBORS = "same_neighbors"; - public SameNeighborsAPI(RestClient client, String graph) { + public SameNeighborsAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -53,7 +53,7 @@ public List get(Object vertexId, Object otherId, params.put("label", label); params.put("max_degree", degree); params.put("limit", limit); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(SAME_NEIGHBORS, Object.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/ShortestPathAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/ShortestPathAPI.java index 4b5cfa99a..9b1693b28 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/ShortestPathAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/ShortestPathAPI.java @@ -22,14 +22,14 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; public class ShortestPathAPI extends TraversersAPI { - public ShortestPathAPI(RestClient client, String graph) { + public ShortestPathAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -58,7 +58,7 @@ public Path get(Object sourceId, Object targetId, params.put("max_degree", degree); params.put("skip_degree", skipDegree); params.put("capacity", capacity); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); List vertices = result.readList("path", Object.class); return new Path(vertices); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SingleSourceShortestPathAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SingleSourceShortestPathAPI.java index a1930fc31..df27e1af8 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SingleSourceShortestPathAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SingleSourceShortestPathAPI.java @@ -21,15 +21,15 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.traverser.WeightedPaths; import org.apache.hugegraph.util.E; public class SingleSourceShortestPathAPI extends TraversersAPI { - public SingleSourceShortestPathAPI(RestClient client, String graph) { + public SingleSourceShortestPathAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -60,7 +60,7 @@ public WeightedPaths get(Object sourceId, Direction direction, String label, params.put("capacity", capacity); params.put("limit", limit); params.put("with_vertex", withVertex); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readObject(WeightedPaths.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TemplatePathsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TemplatePathsAPI.java index 2f198738b..c32c1ec77 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TemplatePathsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TemplatePathsAPI.java @@ -17,14 +17,14 @@ package org.apache.hugegraph.api.traverser; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.traverser.PathsWithVertices; import org.apache.hugegraph.structure.traverser.TemplatePathsRequest; public class TemplatePathsAPI extends TraversersAPI { - public TemplatePathsAPI(RestClient client, String graph) { + public TemplatePathsAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -35,7 +35,7 @@ protected String type() { public PathsWithVertices post(TemplatePathsRequest request) { this.client.checkApiVersion("0.58", "template paths"); - RestResult result = this.client.post(this.path(), request); + OkhttpRestResult result = this.client.post(this.path(), request); return result.readObject(PathsWithVertices.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TraversersAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TraversersAPI.java index 20b765a7f..e14f74ceb 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TraversersAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TraversersAPI.java @@ -18,14 +18,14 @@ package org.apache.hugegraph.api.traverser; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.util.E; public class TraversersAPI extends API { private static final String PATH = "graphs/%s/traversers/%s"; - public TraversersAPI(RestClient client, String graph) { + public TraversersAPI(OkhttpOkhttpRestClient client, String graph) { super(client); this.path(PATH, graph, this.type()); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/VerticesAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/VerticesAPI.java index c80a4fa77..3782689ee 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/VerticesAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/VerticesAPI.java @@ -23,8 +23,8 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.graph.Shard; import org.apache.hugegraph.structure.graph.Vertex; import org.apache.hugegraph.structure.graph.Vertices; @@ -34,7 +34,7 @@ public class VerticesAPI extends TraversersAPI { - public VerticesAPI(RestClient client, String graph) { + public VerticesAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -54,14 +54,14 @@ public List list(List ids) { Map params = new LinkedHashMap<>(); params.put("ids", stringIds); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Vertex.class); } public List shards(long splitSize) { String path = String.join(PATH_SPLITOR, this.path(), "shards"); Map params = ImmutableMap.of("split_size", splitSize); - RestResult result = this.client.get(path, params); + OkhttpRestResult result = this.client.get(path, params); return result.readList("shards", Shard.class); } @@ -73,7 +73,7 @@ public Vertices scan(Shard shard, String page, long pageLimit) { params.put("end", shard.end()); params.put("page", page); params.put("page_limit", pageLimit); - RestResult result = this.client.get(path, params); + OkhttpRestResult result = this.client.get(path, params); return result.readObject(Vertices.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/WeightedShortestPathAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/WeightedShortestPathAPI.java index 7cf2a3b25..4ca19c517 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/WeightedShortestPathAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/WeightedShortestPathAPI.java @@ -21,15 +21,15 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.traverser.WeightedPath; import org.apache.hugegraph.util.E; public class WeightedShortestPathAPI extends TraversersAPI { - public WeightedShortestPathAPI(RestClient client, String graph) { + public WeightedShortestPathAPI(OkhttpOkhttpRestClient client, String graph) { super(client, graph); } @@ -61,7 +61,7 @@ public WeightedPath get(Object sourceId, Object targetId, params.put("skip_degree", skipDegree); params.put("capacity", capacity); params.put("with_vertex", withVertex); - RestResult result = this.client.get(this.path(), params); + OkhttpRestResult result = this.client.get(this.path(), params); return result.readObject(WeightedPath.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/variables/VariablesAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/variables/VariablesAPI.java index 016be729b..8d59c13f7 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/variables/VariablesAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/variables/VariablesAPI.java @@ -20,8 +20,8 @@ import java.util.Map; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.HugeType; import com.google.common.collect.ImmutableMap; @@ -30,7 +30,7 @@ public class VariablesAPI extends API { private static final String PATH = "graphs/%s/%s"; - public VariablesAPI(RestClient client, String graph) { + public VariablesAPI(OkhttpOkhttpRestClient client, String graph) { super(client); this.path(PATH, graph, this.type()); } @@ -42,14 +42,14 @@ protected String type() { @SuppressWarnings("unchecked") public Map get(String key) { - RestResult result = this.client.get(path(), key); + OkhttpRestResult result = this.client.get(path(), key); return result.readObject(Map.class); } @SuppressWarnings("unchecked") public Map set(String key, Object value) { value = ImmutableMap.of("data", value); - RestResult result = this.client.put(this.path(), key, value); + OkhttpRestResult result = this.client.put(this.path(), key, value); return result.readObject(Map.class); } @@ -59,7 +59,7 @@ public void remove(String key) { @SuppressWarnings("unchecked") public Map all() { - RestResult result = this.client.get(path()); + OkhttpRestResult result = this.client.get(path()); return result.readObject(Map.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/version/VersionAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/version/VersionAPI.java index 2071a3411..bd90afdbc 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/version/VersionAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/version/VersionAPI.java @@ -18,14 +18,14 @@ package org.apache.hugegraph.api.version; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.version.Versions; public class VersionAPI extends API { - public VersionAPI(RestClient client) { + public VersionAPI(OkhttpOkhttpRestClient client) { super(client); this.path(this.type()); } @@ -36,7 +36,7 @@ protected String type() { } public Versions get() { - RestResult result = this.client.get(this.path()); + OkhttpRestResult result = this.client.get(this.path()); return result.readObject(Versions.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/client/OkhttpOkhttpRestClient.java similarity index 82% rename from hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java rename to hugegraph-client/src/main/java/org/apache/hugegraph/client/OkhttpOkhttpRestClient.java index d54a1f5d9..7340e3e86 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/client/OkhttpOkhttpRestClient.java @@ -21,16 +21,16 @@ import org.apache.hugegraph.exception.ServerException; import org.apache.hugegraph.serializer.PathDeserializer; import org.apache.hugegraph.structure.graph.Path; -import org.apache.hugegraph.rest.AbstractRestClient; +import org.apache.hugegraph.rest.AbstractOkhttpOkhttpRestClient; import org.apache.hugegraph.rest.ClientException; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.util.E; import org.apache.hugegraph.util.VersionUtil; import org.apache.hugegraph.util.VersionUtil.Version; import com.fasterxml.jackson.databind.module.SimpleModule; -public class RestClient extends AbstractRestClient { +public class OkhttpOkhttpRestClient extends AbstractOkhttpOkhttpRestClient { private static final int SECOND = 1000; @@ -39,17 +39,17 @@ public class RestClient extends AbstractRestClient { static { SimpleModule module = new SimpleModule(); module.addDeserializer(Path.class, new PathDeserializer()); - RestResult.registerModule(module); + OkhttpRestResult.registerModule(module); } - public RestClient(String url, String username, String password, - int timeout) { + public OkhttpOkhttpRestClient(String url, String username, String password, + int timeout) { super(url, username, password, timeout * SECOND); } - public RestClient(String url, String username, String password, int timeout, - int maxConns, int maxConnsPerRoute, - String trustStoreFile, String trustStorePassword) { + public OkhttpOkhttpRestClient(String url, String username, String password, int timeout, + int maxConns, int maxConnsPerRoute, + String trustStoreFile, String trustStorePassword) { super(url, username, password, timeout * SECOND, maxConns, maxConnsPerRoute, trustStoreFile, trustStorePassword); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/AuthManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/AuthManager.java index a15e73534..f56e2f3e0 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/AuthManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/AuthManager.java @@ -31,7 +31,7 @@ import org.apache.hugegraph.api.auth.TargetAPI; import org.apache.hugegraph.api.auth.TokenAPI; import org.apache.hugegraph.api.auth.UserAPI; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.structure.auth.Access; import org.apache.hugegraph.structure.auth.Belong; import org.apache.hugegraph.structure.auth.Group; @@ -54,7 +54,7 @@ public class AuthManager { private final LogoutAPI logoutAPI; private final TokenAPI tokenAPI; - public AuthManager(RestClient client, String graph) { + public AuthManager(OkhttpOkhttpRestClient client, String graph) { this.targetAPI = new TargetAPI(client, graph); this.groupAPI = new GroupAPI(client, graph); this.userAPI = new UserAPI(client, graph); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/CypherManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/CypherManager.java index c53c48a94..fa50be597 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/CypherManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/CypherManager.java @@ -20,14 +20,14 @@ import org.apache.hugegraph.api.gremlin.CypherAPI; import org.apache.hugegraph.structure.gremlin.Response; import org.apache.hugegraph.structure.gremlin.ResultSet; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; public class CypherManager { private final GraphManager graphManager; private final CypherAPI cypherAPI; - public CypherManager(RestClient client, String graph, + public CypherManager(OkhttpOkhttpRestClient client, String graph, GraphManager graphManager) { this.graphManager = graphManager; this.cypherAPI = new CypherAPI(client, graph); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphManager.java index 702d3c2f2..f7a421e26 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphManager.java @@ -28,7 +28,7 @@ import org.apache.hugegraph.structure.GraphElement; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.constant.T; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.structure.graph.BatchEdgeRequest; import org.apache.hugegraph.structure.graph.BatchOlapPropertyRequest; import org.apache.hugegraph.structure.graph.BatchVertexRequest; @@ -43,7 +43,7 @@ public class GraphManager { private final VertexAPI vertexAPI; private final EdgeAPI edgeAPI; - public GraphManager(RestClient client, String graph) { + public GraphManager(OkhttpOkhttpRestClient client, String graph) { this.graph = graph; this.vertexAPI = new VertexAPI(client, graph); this.edgeAPI = new EdgeAPI(client, graph); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphsManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphsManager.java index a9674d876..22cc8ed89 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphsManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphsManager.java @@ -23,13 +23,13 @@ import org.apache.hugegraph.api.graphs.GraphsAPI; import org.apache.hugegraph.structure.constant.GraphMode; import org.apache.hugegraph.structure.constant.GraphReadMode; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; public class GraphsManager { private GraphsAPI graphsAPI; - public GraphsManager(RestClient client) { + public GraphsManager(OkhttpOkhttpRestClient client) { this.graphsAPI = new GraphsAPI(client); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GremlinManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GremlinManager.java index a558e3e15..b6ab7e3ef 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GremlinManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GremlinManager.java @@ -22,7 +22,7 @@ import org.apache.hugegraph.api.job.GremlinJobAPI; import org.apache.hugegraph.structure.gremlin.Response; import org.apache.hugegraph.structure.gremlin.ResultSet; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; public class GremlinManager { @@ -32,7 +32,7 @@ public class GremlinManager { private GremlinJobAPI gremlinJobAPI; private String graph; - public GremlinManager(RestClient client, String graph, + public GremlinManager(OkhttpOkhttpRestClient client, String graph, GraphManager graphManager) { this.graphManager = graphManager; this.gremlinAPI = new GremlinAPI(client); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java index ff525f71e..e9652912d 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java @@ -21,7 +21,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.hugegraph.version.ClientVersion; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.rest.ClientException; import org.apache.hugegraph.util.VersionUtil; @@ -33,7 +33,7 @@ public class HugeClient implements Closeable { ClientVersion.check(); } - private final RestClient client; + private final OkhttpOkhttpRestClient client; private final boolean borrowedClient; private VersionManager version; @@ -52,7 +52,7 @@ public class HugeClient implements Closeable { public HugeClient(HugeClientBuilder builder) { this.borrowedClient = false; try { - this.client = new RestClient(builder.url(), + this.client = new OkhttpOkhttpRestClient(builder.url(), builder.username(), builder.password(), builder.timeout(), @@ -89,7 +89,7 @@ public void close() { } } - private void initManagers(RestClient client, String graph) { + private void initManagers(OkhttpOkhttpRestClient client, String graph) { assert client != null; // Check hugegraph-server api version this.version = new VersionManager(client); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/JobManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/JobManager.java index 501a2e57f..f86723c13 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/JobManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/JobManager.java @@ -22,14 +22,14 @@ import org.apache.hugegraph.structure.schema.EdgeLabel; import org.apache.hugegraph.structure.schema.IndexLabel; import org.apache.hugegraph.structure.schema.VertexLabel; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; public class JobManager { private RebuildAPI rebuildAPI; private TaskAPI taskAPI; - public JobManager(RestClient client, String graph) { + public JobManager(OkhttpOkhttpRestClient client, String graph) { this.rebuildAPI = new RebuildAPI(client, graph); this.taskAPI = new TaskAPI(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/MetricsManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/MetricsManager.java index df6facb12..354ddd77a 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/MetricsManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/MetricsManager.java @@ -20,13 +20,13 @@ import java.util.Map; import org.apache.hugegraph.api.metrics.MetricsAPI; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; public class MetricsManager { private MetricsAPI metricsAPI; - public MetricsManager(RestClient client) { + public MetricsManager(OkhttpOkhttpRestClient client) { this.metricsAPI = new MetricsAPI(client); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/SchemaManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/SchemaManager.java index 8b088db3e..1ceca70be 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/SchemaManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/SchemaManager.java @@ -27,7 +27,7 @@ import org.apache.hugegraph.api.schema.PropertyKeyAPI; import org.apache.hugegraph.api.schema.SchemaAPI; import org.apache.hugegraph.api.schema.VertexLabelAPI; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.structure.schema.BuilderProxy; import org.apache.hugegraph.structure.schema.EdgeLabel; import org.apache.hugegraph.structure.schema.IndexLabel; @@ -43,7 +43,7 @@ public class SchemaManager { private SchemaAPI schemaAPI; private TaskAPI taskAPI; - public SchemaManager(RestClient client, String graph) { + public SchemaManager(OkhttpOkhttpRestClient client, String graph) { this.propertyKeyAPI = new PropertyKeyAPI(client, graph); this.vertexLabelAPI = new VertexLabelAPI(client, graph); this.edgeLabelAPI = new EdgeLabelAPI(client, graph); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/TaskManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/TaskManager.java index 6d92e416b..f22fc856d 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/TaskManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/TaskManager.java @@ -22,13 +22,13 @@ import org.apache.hugegraph.api.task.TaskAPI; import org.apache.hugegraph.api.task.TasksWithPage; import org.apache.hugegraph.structure.Task; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; public class TaskManager { private TaskAPI taskAPI; - public TaskManager(RestClient client, String graph) { + public TaskManager(OkhttpOkhttpRestClient client, String graph) { this.taskAPI = new TaskAPI(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/TraverserManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/TraverserManager.java index 735046a7f..05e6428c3 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/TraverserManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/TraverserManager.java @@ -45,7 +45,7 @@ import org.apache.hugegraph.api.traverser.TemplatePathsAPI; import org.apache.hugegraph.api.traverser.VerticesAPI; import org.apache.hugegraph.api.traverser.WeightedShortestPathAPI; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.structure.graph.Edge; import org.apache.hugegraph.structure.graph.Edges; import org.apache.hugegraph.structure.graph.GraphIterator; @@ -99,7 +99,7 @@ public class TraverserManager { private VerticesAPI verticesAPI; private EdgesAPI edgesAPI; - public TraverserManager(RestClient client, GraphManager graphManager) { + public TraverserManager(OkhttpOkhttpRestClient client, GraphManager graphManager) { this.graphManager = graphManager; String graph = graphManager.graph(); this.jaccardSimilarityAPI = new JaccardSimilarityAPI(client, graph); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/VariablesManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/VariablesManager.java index a62bb708f..d654ea4a3 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/VariablesManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/VariablesManager.java @@ -18,7 +18,7 @@ package org.apache.hugegraph.driver; import org.apache.hugegraph.api.variables.VariablesAPI; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import java.util.Map; @@ -26,7 +26,7 @@ public class VariablesManager { private VariablesAPI variablesAPI; - public VariablesManager(RestClient client, String graph) { + public VariablesManager(OkhttpOkhttpRestClient client, String graph) { this.variablesAPI = new VariablesAPI(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/VersionManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/VersionManager.java index f5283ca68..ad10773ce 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/VersionManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/VersionManager.java @@ -19,13 +19,13 @@ import org.apache.hugegraph.api.version.VersionAPI; import org.apache.hugegraph.structure.version.Versions; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; public class VersionManager { private VersionAPI versionAPI; - public VersionManager(RestClient client) { + public VersionManager(OkhttpOkhttpRestClient client) { this.versionAPI = new VersionAPI(client); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java index 2ba988cd4..8a2fd472c 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java @@ -20,7 +20,7 @@ import java.util.Map; import okhttp3.Response; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.rest.OkhttpRestResult; public class ServerException extends RuntimeException { @@ -40,7 +40,7 @@ public class ServerException extends RuntimeException { private Object trace; public static ServerException fromResponse(Response response) { - RestResult rs = new RestResult(response); + OkhttpRestResult rs = new OkhttpRestResult(response); ServerException exception = new ServerException(rs.content()); exception.status(response.code()); try { diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractOkhttpOkhttpRestClient.java similarity index 77% rename from hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java rename to hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractOkhttpOkhttpRestClient.java index 5020149c7..b993aef4d 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractOkhttpOkhttpRestClient.java @@ -36,33 +36,33 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -public abstract class AbstractRestClient implements RestClient { +public abstract class AbstractOkhttpOkhttpRestClient implements OkhttpRestClient { private OkHttpClient client; private String baseUrl; - public AbstractRestClient(String url, int timeout) { + public AbstractOkhttpOkhttpRestClient(String url, int timeout) { this(url, OkhttpConfig.builder() .timeout(timeout) .build()); } - public AbstractRestClient(String url, String user, String password, - Integer timeout) { + public AbstractOkhttpOkhttpRestClient(String url, String user, String password, + Integer timeout) { this(url, OkhttpConfig.builder() .user(user).password(password) .timeout(timeout) .build()); } - public AbstractRestClient(String url, int timeout, - int maxTotal, int maxPerRoute) { + public AbstractOkhttpOkhttpRestClient(String url, int timeout, + int maxTotal, int maxPerRoute) { this(url, null, null, timeout, maxTotal, maxPerRoute); } - public AbstractRestClient(String url, int timeout, int idleTime, - int maxTotal, int maxPerRoute) { + public AbstractOkhttpOkhttpRestClient(String url, int timeout, int idleTime, + int maxTotal, int maxPerRoute) { this(url, OkhttpConfig.builder() .idleTime(idleTime) .timeout(timeout) @@ -71,8 +71,8 @@ public AbstractRestClient(String url, int timeout, int idleTime, .build()); } - public AbstractRestClient(String url, String user, String password, - int timeout, int maxTotal, int maxPerRoute) { + public AbstractOkhttpOkhttpRestClient(String url, String user, String password, + int timeout, int maxTotal, int maxPerRoute) { this(url, OkhttpConfig.builder() .user(user).password(password) .timeout(timeout) @@ -81,10 +81,10 @@ public AbstractRestClient(String url, String user, String password, .build()); } - public AbstractRestClient(String url, String user, String password, - int timeout, int maxTotal, int maxPerRoute, - String trustStoreFile, - String trustStorePassword) { + public AbstractOkhttpOkhttpRestClient(String url, String user, String password, + int timeout, int maxTotal, int maxPerRoute, + String trustStoreFile, + String trustStorePassword) { this(url, OkhttpConfig.builder() .user(user).password(password) .timeout(timeout) @@ -95,15 +95,15 @@ public AbstractRestClient(String url, String user, String password, .build()); } - public AbstractRestClient(String url, String token, Integer timeout) { + public AbstractOkhttpOkhttpRestClient(String url, String token, Integer timeout) { this(url, OkhttpConfig.builder() .token(token) .timeout(timeout) .build()); } - public AbstractRestClient(String url, String token, Integer timeout, - Integer maxTotal, Integer maxPerRoute) { + public AbstractOkhttpOkhttpRestClient(String url, String token, Integer timeout, + Integer maxTotal, Integer maxPerRoute) { this(url,OkhttpConfig.builder() .token(token) .timeout(timeout) @@ -112,10 +112,10 @@ public AbstractRestClient(String url, String token, Integer timeout, .build()); } - public AbstractRestClient(String url, String token, Integer timeout, - Integer maxTotal, Integer maxPerRoute, - String trustStoreFile, - String trustStorePassword) { + public AbstractOkhttpOkhttpRestClient(String url, String token, Integer timeout, + Integer maxTotal, Integer maxPerRoute, + String trustStoreFile, + String trustStorePassword) { this(url,OkhttpConfig.builder() .token(token) .timeout(timeout) @@ -126,7 +126,7 @@ public AbstractRestClient(String url, String token, Integer timeout, .build()); } - public AbstractRestClient(String url, OkhttpConfig okhttpConfig) { + public AbstractOkhttpOkhttpRestClient(String url, OkhttpConfig okhttpConfig) { this.baseUrl = url; this.client = getOkhttpClient(okhttpConfig); } @@ -147,10 +147,10 @@ private OkHttpClient getOkhttpClient(OkhttpConfig okhttpConfig) { //auth if(StringUtils.isNotBlank(okhttpConfig.getUser()) && StringUtils.isNotBlank(okhttpConfig.getPassword())) { - builder.addInterceptor(new BasicAuthInterceptor(okhttpConfig.getUser(), okhttpConfig.getPassword())); + builder.addInterceptor(new OkhttpBasicAuthInterceptor(okhttpConfig.getUser(), okhttpConfig.getPassword())); } if(StringUtils.isNotBlank(okhttpConfig.getToken())) { - builder.addInterceptor(new TokenInterceptor(okhttpConfig.getToken())); + builder.addInterceptor(new OkhttpTokenInterceptor(okhttpConfig.getToken())); } //ssl @@ -185,17 +185,17 @@ private void configSsl(OkHttpClient.Builder builder, String url, String trustSto } @Override - public RestResult post(String path, Object object) { + public OkhttpRestResult post(String path, Object object) { return this.post(path, object, null, null); } @Override - public RestResult post(String path, Object object, Headers headers) { + public OkhttpRestResult post(String path, Object object, Headers headers) { return this.post(path, object, headers, null); } @Override - public RestResult post(String path, Object object, Map params) { + public OkhttpRestResult post(String path, Object object, Map params) { return this.post(path, object, null, params); } @@ -265,46 +265,46 @@ private static RequestBody gzip(final RequestBody body) { @SneakyThrows @Override - public RestResult post(String path, Object object, - Headers headers, - Map params) { + public OkhttpRestResult post(String path, Object object, + Headers headers, + Map params) { Request.Builder requestBuilder = getRequestBuilder(path, null, headers, params); requestBuilder.post(getRequestBody(object, headers)); try (Response response = client.newCall(requestBuilder.build()).execute()) { checkStatus(response, 200, 201, 202); - return new RestResult(response); + return new OkhttpRestResult(response); } } @Override - public RestResult put(String path, String id, Object object) { + public OkhttpRestResult put(String path, String id, Object object) { return this.put(path, id, object, ImmutableMap.of()); } @Override - public RestResult put(String path, String id, Object object, - Headers headers) { + public OkhttpRestResult put(String path, String id, Object object, + Headers headers) { return this.put(path, id, object, headers, null); } @Override - public RestResult put(String path, String id, Object object, - Map params) { + public OkhttpRestResult put(String path, String id, Object object, + Map params) { return this.put(path, id, object, null, params); } @SneakyThrows @Override - public RestResult put(String path, String id, Object object, - Headers headers, - Map params) { + public OkhttpRestResult put(String path, String id, Object object, + Headers headers, + Map params) { Request.Builder requestBuilder = getRequestBuilder(path, id, headers, params); requestBuilder.put(getRequestBody(object, headers)); try (Response response = client.newCall(requestBuilder.build()).execute()) { checkStatus(response, 200, 202); - return new RestResult(response); + return new OkhttpRestResult(response); } } @@ -319,50 +319,50 @@ private static String parseContentType(Headers headers) { } @Override - public RestResult get(String path) { + public OkhttpRestResult get(String path) { return this.get(path, null, ImmutableMap.of()); } @Override - public RestResult get(String path, Map params) { + public OkhttpRestResult get(String path, Map params) { return this.get(path, null, params); } @Override - public RestResult get(String path, String id) { + public OkhttpRestResult get(String path, String id) { return this.get(path, id, ImmutableMap.of()); } @SneakyThrows - private RestResult get(String path, String id, Map params) { + private OkhttpRestResult get(String path, String id, Map params) { Request.Builder requestBuilder = getRequestBuilder(path, id, null, params); try (Response response = client.newCall(requestBuilder.build()).execute()) { checkStatus(response, 200); - return new RestResult(response); + return new OkhttpRestResult(response); } } @Override - public RestResult delete(String path, Map params) { + public OkhttpRestResult delete(String path, Map params) { return this.delete(path, null, params); } @Override - public RestResult delete(String path, String id) { + public OkhttpRestResult delete(String path, String id) { return this.delete(path, id, ImmutableMap.of()); } @SneakyThrows - private RestResult delete(String path, String id, - Map params) { + private OkhttpRestResult delete(String path, String id, + Map params) { Request.Builder requestBuilder = getRequestBuilder(path, id, null, params); requestBuilder.delete(); try (Response response = client.newCall(requestBuilder.build()).execute()) { checkStatus(response, 204, 202); - return new RestResult(response); + return new OkhttpRestResult(response); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/BasicAuthInterceptor.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpBasicAuthInterceptor.java similarity index 91% rename from hugegraph-client/src/main/java/org/apache/hugegraph/rest/BasicAuthInterceptor.java rename to hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpBasicAuthInterceptor.java index 12477263b..7a0e69691 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/BasicAuthInterceptor.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpBasicAuthInterceptor.java @@ -24,11 +24,11 @@ import java.io.IOException; -public class BasicAuthInterceptor implements Interceptor { +public class OkhttpBasicAuthInterceptor implements Interceptor { private String credentials; - public BasicAuthInterceptor(String user, String password) { + public OkhttpBasicAuthInterceptor(String user, String password) { this.credentials = Credentials.basic(user, password); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/RestClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpRestClient.java similarity index 50% rename from hugegraph-client/src/main/java/org/apache/hugegraph/rest/RestClient.java rename to hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpRestClient.java index 0f951f842..dcaf1886c 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/RestClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpRestClient.java @@ -21,44 +21,44 @@ import java.util.Map; -public interface RestClient { +public interface OkhttpRestClient { /** * Post method */ - RestResult post(String path, Object object); + OkhttpRestResult post(String path, Object object); - RestResult post(String path, Object object, Headers headers); - RestResult post(String path, Object object, Map params); + OkhttpRestResult post(String path, Object object, Headers headers); + OkhttpRestResult post(String path, Object object, Map params); - RestResult post(String path, Object object, Headers headers, - Map params); + OkhttpRestResult post(String path, Object object, Headers headers, + Map params); /** * Put method */ - RestResult put(String path, String id, Object object); - RestResult put(String path, String id, Object object, Headers headers); + OkhttpRestResult put(String path, String id, Object object); + OkhttpRestResult put(String path, String id, Object object, Headers headers); - RestResult put(String path, String id, Object object, Map params); + OkhttpRestResult put(String path, String id, Object object, Map params); - RestResult put(String path, String id, Object object, Headers headers, - Map params); + OkhttpRestResult put(String path, String id, Object object, Headers headers, + Map params); /** * Get method */ - RestResult get(String path); + OkhttpRestResult get(String path); - RestResult get(String path, Map params); + OkhttpRestResult get(String path, Map params); - RestResult get(String path, String id); + OkhttpRestResult get(String path, String id); /** * Delete method */ - RestResult delete(String path, Map params); + OkhttpRestResult delete(String path, Map params); - RestResult delete(String path, String id); + OkhttpRestResult delete(String path, String id); void close(); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/RestResult.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpRestResult.java similarity index 95% rename from hugegraph-client/src/main/java/org/apache/hugegraph/rest/RestResult.java rename to hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpRestResult.java index a284a7ae6..f2ffc6d60 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/RestResult.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpRestResult.java @@ -29,7 +29,7 @@ import java.util.ArrayList; import java.util.List; -public class RestResult { +public class OkhttpRestResult { private static final ObjectMapper MAPPER = new ObjectMapper(); @@ -37,7 +37,7 @@ public class RestResult { private final Headers headers; private final String content; - public RestResult(Response response) { + public OkhttpRestResult(Response response) { this(response.code(), getResponseContent(response), response.headers()); } @@ -46,8 +46,8 @@ private static String getResponseContent(Response response) { return response.body().string(); } - public RestResult(int status, String content, - Headers headers) { + public OkhttpRestResult(int status, String content, + Headers headers) { this.status = status; this.headers = headers; this.content = content; diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/TokenInterceptor.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpTokenInterceptor.java similarity index 92% rename from hugegraph-client/src/main/java/org/apache/hugegraph/rest/TokenInterceptor.java rename to hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpTokenInterceptor.java index f9317ff62..8a3be2835 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/TokenInterceptor.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpTokenInterceptor.java @@ -23,11 +23,11 @@ import java.io.IOException; -public class TokenInterceptor implements Interceptor { +public class OkhttpTokenInterceptor implements Interceptor { private String token; - public TokenInterceptor(String token) { + public OkhttpTokenInterceptor(String token) { this.token = token; } diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/api/BaseApiTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/api/BaseApiTest.java index 37e88622e..97e0e0704 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/api/BaseApiTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/api/BaseApiTest.java @@ -33,7 +33,7 @@ import org.apache.hugegraph.api.task.TaskAPI; import org.apache.hugegraph.api.variables.VariablesAPI; import org.apache.hugegraph.api.version.VersionAPI; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.testutil.Assert; import org.apache.hugegraph.util.VersionUtil; import org.junit.AfterClass; @@ -41,7 +41,7 @@ public class BaseApiTest extends BaseClientTest { - protected static RestClient client; + protected static OkhttpOkhttpRestClient client; protected static VersionAPI versionAPI; protected static GraphsAPI graphsAPI; @@ -59,8 +59,8 @@ public class BaseApiTest extends BaseClientTest { protected static TaskAPI taskAPI; protected static RebuildAPI rebuildAPI; - protected static RestClient initClient() { - client = new RestClient(BASE_URL, USERNAME, PASSWORD, TIMEOUT); + protected static OkhttpOkhttpRestClient initClient() { + client = new OkhttpOkhttpRestClient(BASE_URL, USERNAME, PASSWORD, TIMEOUT); return client; } @@ -101,7 +101,7 @@ public static void clear() throws Exception { BaseClientTest.clear(); } - protected RestClient client() { + protected OkhttpOkhttpRestClient client() { return client; } diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/LogoutApiTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/LogoutApiTest.java index 0652fb3b4..4b479cbe8 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/LogoutApiTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/LogoutApiTest.java @@ -19,7 +19,7 @@ import java.util.List; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.exception.ServerException; import org.apache.hugegraph.structure.auth.Login; import org.apache.hugegraph.structure.auth.LoginResult; @@ -77,7 +77,7 @@ public void testLogout() { }); String token = result.token(); - RestClient client = Whitebox.getInternalState(logoutAPI, "client"); + OkhttpOkhttpRestClient client = Whitebox.getInternalState(logoutAPI, "client"); client.setAuthContext("Bearer " + token); logoutAPI.logout(); } diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/TokenApiTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/TokenApiTest.java index 8ac29e144..689ebaf6e 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/TokenApiTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/TokenApiTest.java @@ -19,7 +19,7 @@ import java.util.List; -import org.apache.hugegraph.client.RestClient; +import org.apache.hugegraph.client.OkhttpOkhttpRestClient; import org.apache.hugegraph.exception.ServerException; import org.apache.hugegraph.structure.auth.Login; import org.apache.hugegraph.structure.auth.LoginResult; @@ -80,7 +80,7 @@ public void testVerify() { }); String token = result.token(); - RestClient client = Whitebox.getInternalState(tokenAPI, "client"); + OkhttpOkhttpRestClient client = Whitebox.getInternalState(tokenAPI, "client"); client.setAuthContext("Bearer " + token); TokenPayload payload = tokenAPI.verifyToken(); @@ -94,7 +94,7 @@ public void testVerify() { Assert.assertContains("Invalid token", e.getMessage()); }); - RestClient client2 = Whitebox.getInternalState(logoutAPI, "client"); + OkhttpOkhttpRestClient client2 = Whitebox.getInternalState(logoutAPI, "client"); Assert.assertThrows(ServerException.class, () -> { logoutAPI.logout(); }, e -> { diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java index 60b44ba78..c19233535 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java @@ -24,7 +24,7 @@ import lombok.SneakyThrows; import org.apache.hugegraph.driver.GraphManager; -import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.serializer.PathDeserializer; import org.apache.hugegraph.structure.constant.Cardinality; import org.apache.hugegraph.structure.constant.DataType; @@ -65,7 +65,7 @@ public static void init() { SimpleModule module = new SimpleModule(); module.addDeserializer(Path.class, new PathDeserializer()); - RestResult.registerModule(module); + OkhttpRestResult.registerModule(module); } public static GraphManager graph() { @@ -98,7 +98,7 @@ public void testReadPropertyKey() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult result = new RestResult(this.mockResponse); + OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, result.status()); Assert.assertNull(result.headers()); @@ -133,7 +133,7 @@ public void testReadPropertyKeys() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult result = new RestResult(this.mockResponse); + OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, result.status()); Assert.assertNull(result.headers()); @@ -170,7 +170,7 @@ public void testReadVertexLabel() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult result = new RestResult(this.mockResponse); + OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, result.status()); Assert.assertNull(result.headers()); @@ -210,7 +210,7 @@ public void testReadVertexLabels() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult result = new RestResult(this.mockResponse); + OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, result.status()); Assert.assertNull(result.headers()); @@ -253,7 +253,7 @@ public void testReadEdgeLabel() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult result = new RestResult(this.mockResponse); + OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, result.status()); Assert.assertNull(result.headers()); @@ -296,7 +296,7 @@ public void testReadEdgeLabels() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult result = new RestResult(this.mockResponse); + OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, result.status()); Assert.assertNull(result.headers()); @@ -338,7 +338,7 @@ public void testReadIndexLabel() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult result = new RestResult(this.mockResponse); + OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, result.status()); Assert.assertNull(result.headers()); @@ -378,7 +378,7 @@ public void testReadIndexLabels() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult result = new RestResult(this.mockResponse); + OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, result.status()); Assert.assertNull(result.headers()); @@ -419,7 +419,7 @@ public void testReadVertex() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult result = new RestResult(this.mockResponse); + OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, result.status()); Assert.assertNull(result.headers()); @@ -471,7 +471,7 @@ public void testReadVertices() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult result = new RestResult(this.mockResponse); + OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, result.status()); Assert.assertNull(result.headers()); @@ -529,7 +529,7 @@ public void testReadEdge() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult result = new RestResult(this.mockResponse); + OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, result.status()); Assert.assertNull(result.headers()); @@ -581,7 +581,7 @@ public void testReadEdges() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult result = new RestResult(this.mockResponse); + OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, result.status()); Assert.assertNull(result.headers()); @@ -661,7 +661,7 @@ public void testReadGremlinVertices() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult restResult = new RestResult(this.mockResponse); + OkhttpRestResult restResult = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); Assert.assertNull(restResult.headers()); @@ -750,7 +750,7 @@ public void testReadGremlinEdges() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult restResult = new RestResult(this.mockResponse); + OkhttpRestResult restResult = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); Assert.assertNull(restResult.headers()); @@ -839,7 +839,7 @@ public void testReadGremlinPathWithVertexAndEdge() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult restResult = new RestResult(this.mockResponse); + OkhttpRestResult restResult = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); Assert.assertNull(restResult.headers()); @@ -898,7 +898,7 @@ public void testReadGremlinNullData() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult restResult = new RestResult(this.mockResponse); + OkhttpRestResult restResult = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); Assert.assertNull(restResult.headers()); @@ -944,7 +944,7 @@ public void testReadGremlinNullAndVertex() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult restResult = new RestResult(this.mockResponse); + OkhttpRestResult restResult = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); Assert.assertNull(restResult.headers()); @@ -1005,7 +1005,7 @@ public void testReadGremlinEdgeAndNull() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - RestResult restResult = new RestResult(this.mockResponse); + OkhttpRestResult restResult = new OkhttpRestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); Assert.assertNull(restResult.headers()); diff --git a/hugegraph-hubble/hubble-be/pom.xml b/hugegraph-hubble/hubble-be/pom.xml index fe7b686d1..23a5af0fc 100644 --- a/hugegraph-hubble/hubble-be/pom.xml +++ b/hugegraph-hubble/hubble-be/pom.xml @@ -92,6 +92,24 @@ org.apache.hugegraph hugegraph-common + + + org.glassfish.jersey.core + jersey-client + + + org.glassfish.jersey.media + jersey-media-json-jackson + + + org.glassfish.jersey.connectors + jersey-apache-connector + + + org.glassfish.jersey.inject + jersey-hk2 + + diff --git a/hugegraph-hubble/pom.xml b/hugegraph-hubble/pom.xml index e9f239b49..ca80db511 100644 --- a/hugegraph-hubble/pom.xml +++ b/hugegraph-hubble/pom.xml @@ -47,13 +47,13 @@ - - org.glassfish.jersey - jersey-bom - ${jersey.version} - pom - import - + + + + + + + com.fasterxml.jackson jackson-bom diff --git a/pom.xml b/pom.xml index 192733125..2effe13cf 100644 --- a/pom.xml +++ b/pom.xml @@ -124,7 +124,7 @@ 2.2.3 3.3.1 3.6.2 - 3.0.3 + 4.12 2.8.47 1.18.8 @@ -151,17 +151,35 @@ - - org.glassfish.jersey - jersey-bom - ${jersey.version} - pom - import - + + + + + + + org.apache.hugegraph hugegraph-common ${hugegraph.common.version} + + + org.glassfish.jersey.core + jersey-client + + + org.glassfish.jersey.media + jersey-media-json-jackson + + + org.glassfish.jersey.connectors + jersey-apache-connector + + + org.glassfish.jersey.inject + jersey-hk2 + + From 1975bfd5afddbe7549149666924537b086c93155 Mon Sep 17 00:00:00 2001 From: tianzy Date: Thu, 17 Aug 2023 21:56:21 +0800 Subject: [PATCH 13/53] add workflow_dispatch --- .github/workflows/hubble-ci.yml | 1 + .github/workflows/loader-ci.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/hubble-ci.yml b/.github/workflows/hubble-ci.yml index 007b45f6d..af3b97878 100644 --- a/.github/workflows/hubble-ci.yml +++ b/.github/workflows/hubble-ci.yml @@ -1,6 +1,7 @@ name: "hugegraph-hubble-ci" on: + workflow_dispatch: push: branches: - master diff --git a/.github/workflows/loader-ci.yml b/.github/workflows/loader-ci.yml index ad4f52894..22d9a2e4c 100644 --- a/.github/workflows/loader-ci.yml +++ b/.github/workflows/loader-ci.yml @@ -1,6 +1,7 @@ name: "hugegraph-loader-ci" on: + workflow_dispatch: push: branches: - master From ae9de53d5f74e7660cd025a0fd1d5245242570f7 Mon Sep 17 00:00:00 2001 From: tianzy Date: Thu, 17 Aug 2023 23:04:19 +0800 Subject: [PATCH 14/53] add workflow_dispatch --- .github/workflows/hubble-ci.yml | 1 + .github/workflows/loader-ci.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/hubble-ci.yml b/.github/workflows/hubble-ci.yml index 007b45f6d..af3b97878 100644 --- a/.github/workflows/hubble-ci.yml +++ b/.github/workflows/hubble-ci.yml @@ -1,6 +1,7 @@ name: "hugegraph-hubble-ci" on: + workflow_dispatch: push: branches: - master diff --git a/.github/workflows/loader-ci.yml b/.github/workflows/loader-ci.yml index ad4f52894..22d9a2e4c 100644 --- a/.github/workflows/loader-ci.yml +++ b/.github/workflows/loader-ci.yml @@ -1,6 +1,7 @@ name: "hugegraph-loader-ci" on: + workflow_dispatch: push: branches: - master From ecc5580b65bf6137ca42252ddde6791da3907609 Mon Sep 17 00:00:00 2001 From: tianzy Date: Thu, 17 Aug 2023 23:57:23 +0800 Subject: [PATCH 15/53] hubble error fix --- hugegraph-hubble/hubble-be/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hugegraph-hubble/hubble-be/pom.xml b/hugegraph-hubble/hubble-be/pom.xml index 23a5af0fc..797cbdbee 100644 --- a/hugegraph-hubble/hubble-be/pom.xml +++ b/hugegraph-hubble/hubble-be/pom.xml @@ -157,6 +157,10 @@ log4j log4j + + com.squareup.okhttp + okhttp + From 57407013e400b8bab38109f65c913f8a7784c47c Mon Sep 17 00:00:00 2001 From: tianzy Date: Fri, 18 Aug 2023 00:35:26 +0800 Subject: [PATCH 16/53] update okhttp version of hubble --- hugegraph-hubble/hubble-be/pom.xml | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/hugegraph-hubble/hubble-be/pom.xml b/hugegraph-hubble/hubble-be/pom.xml index 797cbdbee..d07f7d824 100644 --- a/hugegraph-hubble/hubble-be/pom.xml +++ b/hugegraph-hubble/hubble-be/pom.xml @@ -31,6 +31,7 @@ 36320 2.1.0 3.3.0 + 4.10.0 @@ -157,12 +158,30 @@ log4j log4j + + org.jetbrains.kotlin + kotlin-stdlib + com.squareup.okhttp okhttp + + com.squareup.okhttp3 + okhttp + + + org.jetbrains.kotlin + kotlin-stdlib + 1.6.20 + + + org.jetbrains.kotlin + kotlin-stdlib-common + 1.5.31 + commons-fileupload @@ -170,6 +189,18 @@ + + + + com.squareup.okhttp3 + okhttp-bom + ${okhttp.version} + pom + import + + + + unit-test From ef7846fa0daef2d2315b35e3997f7cfaed8a6154 Mon Sep 17 00:00:00 2001 From: tianzy Date: Fri, 18 Aug 2023 00:57:01 +0800 Subject: [PATCH 17/53] refactor class name --- .../java/org/apache/hugegraph/api/API.java | 6 +-- .../apache/hugegraph/api/auth/AccessAPI.java | 4 +- .../apache/hugegraph/api/auth/AuthAPI.java | 4 +- .../apache/hugegraph/api/auth/BelongAPI.java | 4 +- .../apache/hugegraph/api/auth/GroupAPI.java | 4 +- .../apache/hugegraph/api/auth/LoginAPI.java | 4 +- .../apache/hugegraph/api/auth/LogoutAPI.java | 4 +- .../apache/hugegraph/api/auth/ProjectAPI.java | 4 +- .../apache/hugegraph/api/auth/TargetAPI.java | 4 +- .../apache/hugegraph/api/auth/TokenAPI.java | 4 +- .../apache/hugegraph/api/auth/UserAPI.java | 4 +- .../apache/hugegraph/api/graph/EdgeAPI.java | 4 +- .../apache/hugegraph/api/graph/GraphAPI.java | 4 +- .../apache/hugegraph/api/graph/VertexAPI.java | 4 +- .../hugegraph/api/graphs/GraphsAPI.java | 4 +- .../hugegraph/api/gremlin/CypherAPI.java | 4 +- .../hugegraph/api/gremlin/GremlinAPI.java | 4 +- .../hugegraph/api/job/GremlinJobAPI.java | 4 +- .../org/apache/hugegraph/api/job/JobAPI.java | 4 +- .../apache/hugegraph/api/job/RebuildAPI.java | 4 +- .../hugegraph/api/metrics/MetricsAPI.java | 4 +- .../hugegraph/api/schema/EdgeLabelAPI.java | 4 +- .../hugegraph/api/schema/IndexLabelAPI.java | 4 +- .../hugegraph/api/schema/PropertyKeyAPI.java | 4 +- .../hugegraph/api/schema/SchemaAPI.java | 4 +- .../api/schema/SchemaElementAPI.java | 4 +- .../hugegraph/api/schema/VertexLabelAPI.java | 4 +- .../apache/hugegraph/api/task/TaskAPI.java | 4 +- .../api/traverser/AllShortestPathsAPI.java | 4 +- .../hugegraph/api/traverser/CountAPI.java | 4 +- .../api/traverser/CrosspointsAPI.java | 4 +- .../traverser/CustomizedCrosspointsAPI.java | 4 +- .../api/traverser/CustomizedPathsAPI.java | 4 +- .../hugegraph/api/traverser/EdgesAPI.java | 4 +- .../api/traverser/FusiformSimilarityAPI.java | 4 +- .../api/traverser/JaccardSimilarityAPI.java | 4 +- .../hugegraph/api/traverser/KneighborAPI.java | 4 +- .../hugegraph/api/traverser/KoutAPI.java | 4 +- .../traverser/MultiNodeShortestPathAPI.java | 4 +- .../api/traverser/NeighborRankAPI.java | 4 +- .../hugegraph/api/traverser/PathsAPI.java | 4 +- .../api/traverser/PersonalRankAPI.java | 4 +- .../hugegraph/api/traverser/RaysAPI.java | 4 +- .../hugegraph/api/traverser/RingsAPI.java | 4 +- .../api/traverser/SameNeighborsAPI.java | 4 +- .../api/traverser/ShortestPathAPI.java | 4 +- .../SingleSourceShortestPathAPI.java | 4 +- .../api/traverser/TemplatePathsAPI.java | 4 +- .../api/traverser/TraversersAPI.java | 4 +- .../hugegraph/api/traverser/VerticesAPI.java | 4 +- .../traverser/WeightedShortestPathAPI.java | 4 +- .../hugegraph/api/variables/VariablesAPI.java | 4 +- .../hugegraph/api/version/VersionAPI.java | 4 +- ...pOkhttpRestClient.java => RestClient.java} | 14 +++--- .../apache/hugegraph/driver/AuthManager.java | 4 +- .../hugegraph/driver/CypherManager.java | 4 +- .../apache/hugegraph/driver/GraphManager.java | 4 +- .../hugegraph/driver/GraphsManager.java | 4 +- .../hugegraph/driver/GremlinManager.java | 4 +- .../apache/hugegraph/driver/HugeClient.java | 8 ++-- .../apache/hugegraph/driver/JobManager.java | 4 +- .../hugegraph/driver/MetricsManager.java | 4 +- .../hugegraph/driver/SchemaManager.java | 4 +- .../apache/hugegraph/driver/TaskManager.java | 4 +- .../hugegraph/driver/TraverserManager.java | 4 +- .../hugegraph/driver/VariablesManager.java | 4 +- .../hugegraph/driver/VersionManager.java | 4 +- ...ent.java => OkhttpAbstractRestClient.java} | 44 +++++++++---------- .../org/apache/hugegraph/api/BaseApiTest.java | 10 ++--- .../hugegraph/api/auth/LogoutApiTest.java | 4 +- .../hugegraph/api/auth/TokenApiTest.java | 6 +-- 71 files changed, 174 insertions(+), 174 deletions(-) rename hugegraph-client/src/main/java/org/apache/hugegraph/client/{OkhttpOkhttpRestClient.java => RestClient.java} (85%) rename hugegraph-client/src/main/java/org/apache/hugegraph/rest/{AbstractOkhttpOkhttpRestClient.java => OkhttpAbstractRestClient.java} (89%) diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/API.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/API.java index 7f2aea9ec..1f9d5025d 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/API.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/API.java @@ -17,7 +17,7 @@ package org.apache.hugegraph.api; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.util.E; public abstract class API { @@ -27,11 +27,11 @@ public abstract class API { public static final long NO_LIMIT = -1L; public static final String PATH_SPLITOR = "/"; - protected final OkhttpOkhttpRestClient client; + protected final RestClient client; private String path; - public API(OkhttpOkhttpRestClient client) { + public API(RestClient client) { E.checkNotNull(client, "client"); this.client = client; this.path = null; diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AccessAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AccessAPI.java index fe8fca28c..ad49eb267 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AccessAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AccessAPI.java @@ -21,14 +21,14 @@ import java.util.List; import java.util.Map; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.auth.Access; import org.apache.hugegraph.structure.constant.HugeType; public class AccessAPI extends AuthAPI { - public AccessAPI(OkhttpOkhttpRestClient client, String graph) { + public AccessAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AuthAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AuthAPI.java index f787bec8e..655b4eaf5 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AuthAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AuthAPI.java @@ -18,14 +18,14 @@ package org.apache.hugegraph.api.auth; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.structure.auth.AuthElement; public abstract class AuthAPI extends API { private static final String PATH = "graphs/%s/auth/%s"; - public AuthAPI(OkhttpOkhttpRestClient client, String graph) { + public AuthAPI(RestClient client, String graph) { super(client); this.path(PATH, graph, this.type()); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/BelongAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/BelongAPI.java index 322d1b60e..495fc0626 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/BelongAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/BelongAPI.java @@ -21,14 +21,14 @@ import java.util.List; import java.util.Map; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.auth.Belong; import org.apache.hugegraph.structure.constant.HugeType; public class BelongAPI extends AuthAPI { - public BelongAPI(OkhttpOkhttpRestClient client, String graph) { + public BelongAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/GroupAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/GroupAPI.java index 9f09d04db..cfd6f36ad 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/GroupAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/GroupAPI.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.Map; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.auth.Group; import org.apache.hugegraph.structure.constant.HugeType; @@ -29,7 +29,7 @@ public class GroupAPI extends AuthAPI { - public GroupAPI(OkhttpOkhttpRestClient client, String graph) { + public GroupAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LoginAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LoginAPI.java index ef4e608fb..9d74af0b5 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LoginAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LoginAPI.java @@ -17,7 +17,7 @@ package org.apache.hugegraph.api.auth; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.auth.Login; import org.apache.hugegraph.structure.auth.LoginResult; @@ -25,7 +25,7 @@ public class LoginAPI extends AuthAPI { - public LoginAPI(OkhttpOkhttpRestClient client, String graph) { + public LoginAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LogoutAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LogoutAPI.java index ad6c3980f..c26c5af91 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LogoutAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LogoutAPI.java @@ -17,14 +17,14 @@ package org.apache.hugegraph.api.auth; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.structure.constant.HugeType; import com.google.common.collect.ImmutableMap; public class LogoutAPI extends AuthAPI { - public LogoutAPI(OkhttpOkhttpRestClient client, String graph) { + public LogoutAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/ProjectAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/ProjectAPI.java index d23529af6..af9eefcf0 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/ProjectAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/ProjectAPI.java @@ -21,7 +21,7 @@ import java.util.Map; import java.util.Set; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.auth.Project; import org.apache.hugegraph.structure.constant.HugeType; @@ -33,7 +33,7 @@ public class ProjectAPI extends AuthAPI { private static final String ACTION_ADD_GRAPH = "add_graph"; private static final String ACTION_REMOVE_GRAPH = "remove_graph"; - public ProjectAPI(OkhttpOkhttpRestClient client, String graph) { + public ProjectAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TargetAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TargetAPI.java index 371a15183..488aa3443 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TargetAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TargetAPI.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.Map; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.auth.Target; import org.apache.hugegraph.structure.constant.HugeType; @@ -29,7 +29,7 @@ public class TargetAPI extends AuthAPI { - public TargetAPI(OkhttpOkhttpRestClient client, String graph) { + public TargetAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TokenAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TokenAPI.java index 032a18920..d9605e77e 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TokenAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TokenAPI.java @@ -17,14 +17,14 @@ package org.apache.hugegraph.api.auth; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.auth.TokenPayload; import org.apache.hugegraph.structure.constant.HugeType; public class TokenAPI extends AuthAPI { - public TokenAPI(OkhttpOkhttpRestClient client, String graph) { + public TokenAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java index e0b6eed4e..99c01ef13 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.Map; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.auth.User; import org.apache.hugegraph.structure.auth.User.UserRole; @@ -30,7 +30,7 @@ public class UserAPI extends AuthAPI { - public UserAPI(OkhttpOkhttpRestClient client, String graph) { + public UserAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java index fd4860dce..45d14f107 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java @@ -22,7 +22,7 @@ import java.util.Map; import okhttp3.Headers; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.NotAllCreatedException; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; @@ -35,7 +35,7 @@ public class EdgeAPI extends GraphAPI { - public EdgeAPI(OkhttpOkhttpRestClient client, String graph) { + public EdgeAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java index 3767eb782..d76929dc2 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java @@ -21,7 +21,7 @@ import java.util.UUID; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.util.E; import org.apache.hugegraph.util.JsonUtil; @@ -31,7 +31,7 @@ public abstract class GraphAPI extends API { private final String batchPath; - public GraphAPI(OkhttpOkhttpRestClient client, String graph) { + public GraphAPI(RestClient client, String graph) { super(client); this.path(PATH, graph, this.type()); this.batchPath = String.join("/", this.path(), "batch"); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java index b02022141..2f35a36b1 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java @@ -19,7 +19,7 @@ import com.google.common.collect.ImmutableMap; import okhttp3.Headers; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.InvalidResponseException; import org.apache.hugegraph.exception.NotAllCreatedException; import org.apache.hugegraph.rest.OkhttpRestResult; @@ -35,7 +35,7 @@ public class VertexAPI extends GraphAPI { - public VertexAPI(OkhttpOkhttpRestClient client, String graph) { + public VertexAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java index 902457347..c6842430a 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java @@ -21,7 +21,7 @@ import okhttp3.Headers; import org.apache.commons.lang3.StringUtils; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.InvalidResponseException; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.GraphMode; @@ -40,7 +40,7 @@ public class GraphsAPI extends API { private static final String CONFIRM_MESSAGE = "confirm_message"; - public GraphsAPI(OkhttpOkhttpRestClient client) { + public GraphsAPI(RestClient client) { super(client); this.path(this.type()); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/CypherAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/CypherAPI.java index 6353375c4..1e441efe9 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/CypherAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/CypherAPI.java @@ -18,7 +18,7 @@ package org.apache.hugegraph.api.gremlin; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.gremlin.Response; @@ -27,7 +27,7 @@ public class CypherAPI extends API { private static final String PATH = "graphs/%s/cypher"; - public CypherAPI(OkhttpOkhttpRestClient client, String graph) { + public CypherAPI(RestClient client, String graph) { super(client); this.path(PATH, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/GremlinAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/GremlinAPI.java index d5dbfdf6a..b16d6092c 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/GremlinAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/GremlinAPI.java @@ -18,14 +18,14 @@ package org.apache.hugegraph.api.gremlin; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.gremlin.Response; public class GremlinAPI extends API { - public GremlinAPI(OkhttpOkhttpRestClient client) { + public GremlinAPI(RestClient client) { super(client); this.path(type()); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/GremlinJobAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/GremlinJobAPI.java index 040bd1b1f..4d6e6b388 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/GremlinJobAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/GremlinJobAPI.java @@ -21,14 +21,14 @@ import org.apache.hugegraph.api.gremlin.GremlinRequest; import org.apache.hugegraph.api.task.TaskAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; public class GremlinJobAPI extends JobAPI { private static final String JOB_TYPE = "gremlin"; - public GremlinJobAPI(OkhttpOkhttpRestClient client, String graph) { + public GremlinJobAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/JobAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/JobAPI.java index 0e64c439d..da2300acb 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/JobAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/JobAPI.java @@ -18,7 +18,7 @@ package org.apache.hugegraph.api.job; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.structure.constant.HugeType; public abstract class JobAPI extends API { @@ -26,7 +26,7 @@ public abstract class JobAPI extends API { // For example: graphs/hugegraph/jobs/gremlin private static final String PATH = "graphs/%s/%s/%s"; - public JobAPI(OkhttpOkhttpRestClient client, String graph) { + public JobAPI(RestClient client, String graph) { super(client); this.path(String.format(PATH, graph, this.type(), this.jobType())); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/RebuildAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/RebuildAPI.java index ba20798ed..aae9b574d 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/RebuildAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/RebuildAPI.java @@ -20,7 +20,7 @@ import java.util.Map; import org.apache.hugegraph.api.task.TaskAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.SchemaElement; import org.apache.hugegraph.structure.schema.EdgeLabel; @@ -32,7 +32,7 @@ public class RebuildAPI extends JobAPI { private static final String JOB_TYPE = "rebuild"; - public RebuildAPI(OkhttpOkhttpRestClient client, String graph) { + public RebuildAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java index 0e619aadd..c6388a90f 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java @@ -21,13 +21,13 @@ import org.apache.hugegraph.util.CommonUtil; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.HugeType; public class MetricsAPI extends API { - public MetricsAPI(OkhttpOkhttpRestClient client) { + public MetricsAPI(RestClient client) { super(client); this.path(this.type()); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/EdgeLabelAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/EdgeLabelAPI.java index f74ec058a..0f88fe9de 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/EdgeLabelAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/EdgeLabelAPI.java @@ -21,7 +21,7 @@ import java.util.Map; import org.apache.hugegraph.api.task.TaskAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.SchemaElement; import org.apache.hugegraph.structure.constant.HugeType; @@ -32,7 +32,7 @@ public class EdgeLabelAPI extends SchemaElementAPI { - public EdgeLabelAPI(OkhttpOkhttpRestClient client, String graph) { + public EdgeLabelAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/IndexLabelAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/IndexLabelAPI.java index e301cd9bd..3975eb563 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/IndexLabelAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/IndexLabelAPI.java @@ -21,7 +21,7 @@ import java.util.Map; import org.apache.hugegraph.api.task.TaskAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.NotSupportException; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.SchemaElement; @@ -34,7 +34,7 @@ public class IndexLabelAPI extends SchemaElementAPI { - public IndexLabelAPI(OkhttpOkhttpRestClient client, String graph) { + public IndexLabelAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/PropertyKeyAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/PropertyKeyAPI.java index 34cb5bca8..783a2a3fd 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/PropertyKeyAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/PropertyKeyAPI.java @@ -21,7 +21,7 @@ import java.util.Map; import org.apache.hugegraph.api.task.TaskAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.NotSupportException; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.SchemaElement; @@ -34,7 +34,7 @@ public class PropertyKeyAPI extends SchemaElementAPI { - public PropertyKeyAPI(OkhttpOkhttpRestClient client, String graph) { + public PropertyKeyAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaAPI.java index 84e67e278..2c0159d79 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaAPI.java @@ -21,7 +21,7 @@ import java.util.Map; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.NotSupportException; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.SchemaElement; @@ -30,7 +30,7 @@ public class SchemaAPI extends API { private static final String PATH = "graphs/%s/%s"; - public SchemaAPI(OkhttpOkhttpRestClient client, String graph) { + public SchemaAPI(RestClient client, String graph) { super(client); this.path(PATH, graph, this.type()); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaElementAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaElementAPI.java index 781d9d52c..417294476 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaElementAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaElementAPI.java @@ -18,14 +18,14 @@ package org.apache.hugegraph.api.schema; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.structure.SchemaElement; public abstract class SchemaElementAPI extends API { private static final String PATH = "graphs/%s/schema/%s"; - public SchemaElementAPI(OkhttpOkhttpRestClient client, String graph) { + public SchemaElementAPI(RestClient client, String graph) { super(client); this.path(PATH, graph, this.type()); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/VertexLabelAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/VertexLabelAPI.java index 12fa90210..32d5d3204 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/VertexLabelAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/VertexLabelAPI.java @@ -21,7 +21,7 @@ import java.util.Map; import org.apache.hugegraph.api.task.TaskAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.SchemaElement; import org.apache.hugegraph.structure.constant.HugeType; @@ -32,7 +32,7 @@ public class VertexLabelAPI extends SchemaElementAPI { - public VertexLabelAPI(OkhttpOkhttpRestClient client, String graph) { + public VertexLabelAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/task/TaskAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/task/TaskAPI.java index b338d5c70..6e4977e26 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/task/TaskAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/task/TaskAPI.java @@ -23,7 +23,7 @@ import org.apache.hugegraph.util.TaskCache; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.ClientException; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.Task; @@ -41,7 +41,7 @@ public class TaskAPI extends API { public static final long TASK_TIMEOUT = 60L; private static final long QUERY_INTERVAL = 500L; - public TaskAPI(OkhttpOkhttpRestClient client, String graph) { + public TaskAPI(RestClient client, String graph) { super(client); this.path(String.format(PATH, graph)); this.graph = graph; diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/AllShortestPathsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/AllShortestPathsAPI.java index ff99b22cc..580a53ed5 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/AllShortestPathsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/AllShortestPathsAPI.java @@ -22,14 +22,14 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; public class AllShortestPathsAPI extends TraversersAPI { - public AllShortestPathsAPI(OkhttpOkhttpRestClient client, String graph) { + public AllShortestPathsAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CountAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CountAPI.java index 5d9e4bf92..fec6b7053 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CountAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CountAPI.java @@ -19,7 +19,7 @@ import java.util.Map; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.traverser.CountRequest; import org.apache.hugegraph.util.E; @@ -28,7 +28,7 @@ public class CountAPI extends TraversersAPI { private static final String COUNT = "count"; - public CountAPI(OkhttpOkhttpRestClient client, String graph) { + public CountAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CrosspointsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CrosspointsAPI.java index c5c9e7185..91ee8050c 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CrosspointsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CrosspointsAPI.java @@ -22,14 +22,14 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; public class CrosspointsAPI extends TraversersAPI { - public CrosspointsAPI(OkhttpOkhttpRestClient client, String graph) { + public CrosspointsAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedCrosspointsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedCrosspointsAPI.java index 39bbe9f96..378888e45 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedCrosspointsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedCrosspointsAPI.java @@ -17,14 +17,14 @@ package org.apache.hugegraph.api.traverser; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.traverser.CrosspointsRequest; import org.apache.hugegraph.structure.traverser.CustomizedCrosspoints; public class CustomizedCrosspointsAPI extends TraversersAPI { - public CustomizedCrosspointsAPI(OkhttpOkhttpRestClient client, String graph) { + public CustomizedCrosspointsAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedPathsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedPathsAPI.java index 115991e7b..112d4a7f8 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedPathsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedPathsAPI.java @@ -17,14 +17,14 @@ package org.apache.hugegraph.api.traverser; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.traverser.PathsWithVertices; import org.apache.hugegraph.structure.traverser.CustomizedPathsRequest; public class CustomizedPathsAPI extends TraversersAPI { - public CustomizedPathsAPI(OkhttpOkhttpRestClient client, String graph) { + public CustomizedPathsAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/EdgesAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/EdgesAPI.java index d0d828294..2dea2e80d 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/EdgesAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/EdgesAPI.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.Map; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.graph.Edge; import org.apache.hugegraph.structure.graph.Edges; @@ -32,7 +32,7 @@ public class EdgesAPI extends TraversersAPI { - public EdgesAPI(OkhttpOkhttpRestClient client, String graph) { + public EdgesAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/FusiformSimilarityAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/FusiformSimilarityAPI.java index b249b65ad..266590935 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/FusiformSimilarityAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/FusiformSimilarityAPI.java @@ -17,14 +17,14 @@ package org.apache.hugegraph.api.traverser; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.traverser.FusiformSimilarity; import org.apache.hugegraph.structure.traverser.FusiformSimilarityRequest; public class FusiformSimilarityAPI extends TraversersAPI { - public FusiformSimilarityAPI(OkhttpOkhttpRestClient client, String graph) { + public FusiformSimilarityAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java index ba4d8f54a..fee0d25c4 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java @@ -21,7 +21,7 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; @@ -35,7 +35,7 @@ public class JaccardSimilarityAPI extends TraversersAPI { private static final String JACCARD_SIMILARITY = "jaccard_similarity"; - public JaccardSimilarityAPI(OkhttpOkhttpRestClient client, String graph) { + public JaccardSimilarityAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KneighborAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KneighborAPI.java index d8e66ff39..7105b3a7b 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KneighborAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KneighborAPI.java @@ -22,7 +22,7 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.traverser.Kneighbor; @@ -30,7 +30,7 @@ public class KneighborAPI extends TraversersAPI { - public KneighborAPI(OkhttpOkhttpRestClient client, String graph) { + public KneighborAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KoutAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KoutAPI.java index 757e8baa3..91ea1acef 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KoutAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KoutAPI.java @@ -22,7 +22,7 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.traverser.Kout; @@ -30,7 +30,7 @@ public class KoutAPI extends TraversersAPI { - public KoutAPI(OkhttpOkhttpRestClient client, String graph) { + public KoutAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/MultiNodeShortestPathAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/MultiNodeShortestPathAPI.java index 541b4c711..637133536 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/MultiNodeShortestPathAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/MultiNodeShortestPathAPI.java @@ -17,14 +17,14 @@ package org.apache.hugegraph.api.traverser; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.traverser.MultiNodeShortestPathRequest; import org.apache.hugegraph.structure.traverser.PathsWithVertices; public class MultiNodeShortestPathAPI extends TraversersAPI { - public MultiNodeShortestPathAPI(OkhttpOkhttpRestClient client, String graph) { + public MultiNodeShortestPathAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/NeighborRankAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/NeighborRankAPI.java index 8019b2ad7..12cf074ed 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/NeighborRankAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/NeighborRankAPI.java @@ -21,7 +21,7 @@ import java.util.Arrays; import java.util.List; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.constant.Traverser; @@ -32,7 +32,7 @@ public class NeighborRankAPI extends TraversersAPI { - public NeighborRankAPI(OkhttpOkhttpRestClient client, String graph) { + public NeighborRankAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PathsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PathsAPI.java index 7cde5d152..9f2cd8d42 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PathsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PathsAPI.java @@ -22,7 +22,7 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; @@ -31,7 +31,7 @@ public class PathsAPI extends TraversersAPI { - public PathsAPI(OkhttpOkhttpRestClient client, String graph) { + public PathsAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PersonalRankAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PersonalRankAPI.java index 33e09823e..8641bef04 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PersonalRankAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PersonalRankAPI.java @@ -17,7 +17,7 @@ package org.apache.hugegraph.api.traverser; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Traverser; import org.apache.hugegraph.structure.traverser.Ranks; @@ -27,7 +27,7 @@ public class PersonalRankAPI extends TraversersAPI { - public PersonalRankAPI(OkhttpOkhttpRestClient client, String graph) { + public PersonalRankAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RaysAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RaysAPI.java index 3e1517dd7..e164cac35 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RaysAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RaysAPI.java @@ -22,14 +22,14 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; public class RaysAPI extends TraversersAPI { - public RaysAPI(OkhttpOkhttpRestClient client, String graph) { + public RaysAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RingsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RingsAPI.java index b414ab2ac..067b4d4ad 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RingsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RingsAPI.java @@ -22,14 +22,14 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; public class RingsAPI extends TraversersAPI { - public RingsAPI(OkhttpOkhttpRestClient client, String graph) { + public RingsAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SameNeighborsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SameNeighborsAPI.java index c24512d39..7a8687f7a 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SameNeighborsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SameNeighborsAPI.java @@ -22,7 +22,7 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; @@ -30,7 +30,7 @@ public class SameNeighborsAPI extends TraversersAPI { private static final String SAME_NEIGHBORS = "same_neighbors"; - public SameNeighborsAPI(OkhttpOkhttpRestClient client, String graph) { + public SameNeighborsAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/ShortestPathAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/ShortestPathAPI.java index 9b1693b28..e92d6f72c 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/ShortestPathAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/ShortestPathAPI.java @@ -22,14 +22,14 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; public class ShortestPathAPI extends TraversersAPI { - public ShortestPathAPI(OkhttpOkhttpRestClient client, String graph) { + public ShortestPathAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SingleSourceShortestPathAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SingleSourceShortestPathAPI.java index df27e1af8..c095ab145 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SingleSourceShortestPathAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SingleSourceShortestPathAPI.java @@ -21,7 +21,7 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.traverser.WeightedPaths; @@ -29,7 +29,7 @@ public class SingleSourceShortestPathAPI extends TraversersAPI { - public SingleSourceShortestPathAPI(OkhttpOkhttpRestClient client, String graph) { + public SingleSourceShortestPathAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TemplatePathsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TemplatePathsAPI.java index c32c1ec77..bcc99316d 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TemplatePathsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TemplatePathsAPI.java @@ -17,14 +17,14 @@ package org.apache.hugegraph.api.traverser; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.traverser.PathsWithVertices; import org.apache.hugegraph.structure.traverser.TemplatePathsRequest; public class TemplatePathsAPI extends TraversersAPI { - public TemplatePathsAPI(OkhttpOkhttpRestClient client, String graph) { + public TemplatePathsAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TraversersAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TraversersAPI.java index e14f74ceb..20b765a7f 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TraversersAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TraversersAPI.java @@ -18,14 +18,14 @@ package org.apache.hugegraph.api.traverser; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.util.E; public class TraversersAPI extends API { private static final String PATH = "graphs/%s/traversers/%s"; - public TraversersAPI(OkhttpOkhttpRestClient client, String graph) { + public TraversersAPI(RestClient client, String graph) { super(client); this.path(PATH, graph, this.type()); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/VerticesAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/VerticesAPI.java index 3782689ee..3456de36c 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/VerticesAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/VerticesAPI.java @@ -23,7 +23,7 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.graph.Shard; import org.apache.hugegraph.structure.graph.Vertex; @@ -34,7 +34,7 @@ public class VerticesAPI extends TraversersAPI { - public VerticesAPI(OkhttpOkhttpRestClient client, String graph) { + public VerticesAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/WeightedShortestPathAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/WeightedShortestPathAPI.java index 4ca19c517..e400f18fb 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/WeightedShortestPathAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/WeightedShortestPathAPI.java @@ -21,7 +21,7 @@ import java.util.Map; import org.apache.hugegraph.api.graph.GraphAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.traverser.WeightedPath; @@ -29,7 +29,7 @@ public class WeightedShortestPathAPI extends TraversersAPI { - public WeightedShortestPathAPI(OkhttpOkhttpRestClient client, String graph) { + public WeightedShortestPathAPI(RestClient client, String graph) { super(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/variables/VariablesAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/variables/VariablesAPI.java index 8d59c13f7..541a9dcc4 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/variables/VariablesAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/variables/VariablesAPI.java @@ -20,7 +20,7 @@ import java.util.Map; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.HugeType; @@ -30,7 +30,7 @@ public class VariablesAPI extends API { private static final String PATH = "graphs/%s/%s"; - public VariablesAPI(OkhttpOkhttpRestClient client, String graph) { + public VariablesAPI(RestClient client, String graph) { super(client); this.path(PATH, graph, this.type()); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/version/VersionAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/version/VersionAPI.java index bd90afdbc..9a3c42f2c 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/version/VersionAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/version/VersionAPI.java @@ -18,14 +18,14 @@ package org.apache.hugegraph.api.version; import org.apache.hugegraph.api.API; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.version.Versions; public class VersionAPI extends API { - public VersionAPI(OkhttpOkhttpRestClient client) { + public VersionAPI(RestClient client) { super(client); this.path(this.type()); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/client/OkhttpOkhttpRestClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java similarity index 85% rename from hugegraph-client/src/main/java/org/apache/hugegraph/client/OkhttpOkhttpRestClient.java rename to hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java index 7340e3e86..7421d83a6 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/client/OkhttpOkhttpRestClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java @@ -21,7 +21,7 @@ import org.apache.hugegraph.exception.ServerException; import org.apache.hugegraph.serializer.PathDeserializer; import org.apache.hugegraph.structure.graph.Path; -import org.apache.hugegraph.rest.AbstractOkhttpOkhttpRestClient; +import org.apache.hugegraph.rest.OkhttpAbstractRestClient; import org.apache.hugegraph.rest.ClientException; import org.apache.hugegraph.rest.OkhttpRestResult; import org.apache.hugegraph.util.E; @@ -30,7 +30,7 @@ import com.fasterxml.jackson.databind.module.SimpleModule; -public class OkhttpOkhttpRestClient extends AbstractOkhttpOkhttpRestClient { +public class RestClient extends OkhttpAbstractRestClient { private static final int SECOND = 1000; @@ -42,14 +42,14 @@ public class OkhttpOkhttpRestClient extends AbstractOkhttpOkhttpRestClient { OkhttpRestResult.registerModule(module); } - public OkhttpOkhttpRestClient(String url, String username, String password, - int timeout) { + public RestClient(String url, String username, String password, + int timeout) { super(url, username, password, timeout * SECOND); } - public OkhttpOkhttpRestClient(String url, String username, String password, int timeout, - int maxConns, int maxConnsPerRoute, - String trustStoreFile, String trustStorePassword) { + public RestClient(String url, String username, String password, int timeout, + int maxConns, int maxConnsPerRoute, + String trustStoreFile, String trustStorePassword) { super(url, username, password, timeout * SECOND, maxConns, maxConnsPerRoute, trustStoreFile, trustStorePassword); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/AuthManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/AuthManager.java index f56e2f3e0..a15e73534 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/AuthManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/AuthManager.java @@ -31,7 +31,7 @@ import org.apache.hugegraph.api.auth.TargetAPI; import org.apache.hugegraph.api.auth.TokenAPI; import org.apache.hugegraph.api.auth.UserAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.structure.auth.Access; import org.apache.hugegraph.structure.auth.Belong; import org.apache.hugegraph.structure.auth.Group; @@ -54,7 +54,7 @@ public class AuthManager { private final LogoutAPI logoutAPI; private final TokenAPI tokenAPI; - public AuthManager(OkhttpOkhttpRestClient client, String graph) { + public AuthManager(RestClient client, String graph) { this.targetAPI = new TargetAPI(client, graph); this.groupAPI = new GroupAPI(client, graph); this.userAPI = new UserAPI(client, graph); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/CypherManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/CypherManager.java index fa50be597..c53c48a94 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/CypherManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/CypherManager.java @@ -20,14 +20,14 @@ import org.apache.hugegraph.api.gremlin.CypherAPI; import org.apache.hugegraph.structure.gremlin.Response; import org.apache.hugegraph.structure.gremlin.ResultSet; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; public class CypherManager { private final GraphManager graphManager; private final CypherAPI cypherAPI; - public CypherManager(OkhttpOkhttpRestClient client, String graph, + public CypherManager(RestClient client, String graph, GraphManager graphManager) { this.graphManager = graphManager; this.cypherAPI = new CypherAPI(client, graph); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphManager.java index f7a421e26..702d3c2f2 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphManager.java @@ -28,7 +28,7 @@ import org.apache.hugegraph.structure.GraphElement; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.constant.T; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.structure.graph.BatchEdgeRequest; import org.apache.hugegraph.structure.graph.BatchOlapPropertyRequest; import org.apache.hugegraph.structure.graph.BatchVertexRequest; @@ -43,7 +43,7 @@ public class GraphManager { private final VertexAPI vertexAPI; private final EdgeAPI edgeAPI; - public GraphManager(OkhttpOkhttpRestClient client, String graph) { + public GraphManager(RestClient client, String graph) { this.graph = graph; this.vertexAPI = new VertexAPI(client, graph); this.edgeAPI = new EdgeAPI(client, graph); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphsManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphsManager.java index 22cc8ed89..a9674d876 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphsManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphsManager.java @@ -23,13 +23,13 @@ import org.apache.hugegraph.api.graphs.GraphsAPI; import org.apache.hugegraph.structure.constant.GraphMode; import org.apache.hugegraph.structure.constant.GraphReadMode; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; public class GraphsManager { private GraphsAPI graphsAPI; - public GraphsManager(OkhttpOkhttpRestClient client) { + public GraphsManager(RestClient client) { this.graphsAPI = new GraphsAPI(client); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GremlinManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GremlinManager.java index b6ab7e3ef..a558e3e15 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GremlinManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/GremlinManager.java @@ -22,7 +22,7 @@ import org.apache.hugegraph.api.job.GremlinJobAPI; import org.apache.hugegraph.structure.gremlin.Response; import org.apache.hugegraph.structure.gremlin.ResultSet; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; public class GremlinManager { @@ -32,7 +32,7 @@ public class GremlinManager { private GremlinJobAPI gremlinJobAPI; private String graph; - public GremlinManager(OkhttpOkhttpRestClient client, String graph, + public GremlinManager(RestClient client, String graph, GraphManager graphManager) { this.graphManager = graphManager; this.gremlinAPI = new GremlinAPI(client); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java index e9652912d..ff525f71e 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java @@ -21,7 +21,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.hugegraph.version.ClientVersion; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.ClientException; import org.apache.hugegraph.util.VersionUtil; @@ -33,7 +33,7 @@ public class HugeClient implements Closeable { ClientVersion.check(); } - private final OkhttpOkhttpRestClient client; + private final RestClient client; private final boolean borrowedClient; private VersionManager version; @@ -52,7 +52,7 @@ public class HugeClient implements Closeable { public HugeClient(HugeClientBuilder builder) { this.borrowedClient = false; try { - this.client = new OkhttpOkhttpRestClient(builder.url(), + this.client = new RestClient(builder.url(), builder.username(), builder.password(), builder.timeout(), @@ -89,7 +89,7 @@ public void close() { } } - private void initManagers(OkhttpOkhttpRestClient client, String graph) { + private void initManagers(RestClient client, String graph) { assert client != null; // Check hugegraph-server api version this.version = new VersionManager(client); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/JobManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/JobManager.java index f86723c13..501a2e57f 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/JobManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/JobManager.java @@ -22,14 +22,14 @@ import org.apache.hugegraph.structure.schema.EdgeLabel; import org.apache.hugegraph.structure.schema.IndexLabel; import org.apache.hugegraph.structure.schema.VertexLabel; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; public class JobManager { private RebuildAPI rebuildAPI; private TaskAPI taskAPI; - public JobManager(OkhttpOkhttpRestClient client, String graph) { + public JobManager(RestClient client, String graph) { this.rebuildAPI = new RebuildAPI(client, graph); this.taskAPI = new TaskAPI(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/MetricsManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/MetricsManager.java index 354ddd77a..df6facb12 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/MetricsManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/MetricsManager.java @@ -20,13 +20,13 @@ import java.util.Map; import org.apache.hugegraph.api.metrics.MetricsAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; public class MetricsManager { private MetricsAPI metricsAPI; - public MetricsManager(OkhttpOkhttpRestClient client) { + public MetricsManager(RestClient client) { this.metricsAPI = new MetricsAPI(client); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/SchemaManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/SchemaManager.java index 1ceca70be..8b088db3e 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/SchemaManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/SchemaManager.java @@ -27,7 +27,7 @@ import org.apache.hugegraph.api.schema.PropertyKeyAPI; import org.apache.hugegraph.api.schema.SchemaAPI; import org.apache.hugegraph.api.schema.VertexLabelAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.structure.schema.BuilderProxy; import org.apache.hugegraph.structure.schema.EdgeLabel; import org.apache.hugegraph.structure.schema.IndexLabel; @@ -43,7 +43,7 @@ public class SchemaManager { private SchemaAPI schemaAPI; private TaskAPI taskAPI; - public SchemaManager(OkhttpOkhttpRestClient client, String graph) { + public SchemaManager(RestClient client, String graph) { this.propertyKeyAPI = new PropertyKeyAPI(client, graph); this.vertexLabelAPI = new VertexLabelAPI(client, graph); this.edgeLabelAPI = new EdgeLabelAPI(client, graph); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/TaskManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/TaskManager.java index f22fc856d..6d92e416b 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/TaskManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/TaskManager.java @@ -22,13 +22,13 @@ import org.apache.hugegraph.api.task.TaskAPI; import org.apache.hugegraph.api.task.TasksWithPage; import org.apache.hugegraph.structure.Task; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; public class TaskManager { private TaskAPI taskAPI; - public TaskManager(OkhttpOkhttpRestClient client, String graph) { + public TaskManager(RestClient client, String graph) { this.taskAPI = new TaskAPI(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/TraverserManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/TraverserManager.java index 05e6428c3..735046a7f 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/TraverserManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/TraverserManager.java @@ -45,7 +45,7 @@ import org.apache.hugegraph.api.traverser.TemplatePathsAPI; import org.apache.hugegraph.api.traverser.VerticesAPI; import org.apache.hugegraph.api.traverser.WeightedShortestPathAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.structure.graph.Edge; import org.apache.hugegraph.structure.graph.Edges; import org.apache.hugegraph.structure.graph.GraphIterator; @@ -99,7 +99,7 @@ public class TraverserManager { private VerticesAPI verticesAPI; private EdgesAPI edgesAPI; - public TraverserManager(OkhttpOkhttpRestClient client, GraphManager graphManager) { + public TraverserManager(RestClient client, GraphManager graphManager) { this.graphManager = graphManager; String graph = graphManager.graph(); this.jaccardSimilarityAPI = new JaccardSimilarityAPI(client, graph); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/VariablesManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/VariablesManager.java index d654ea4a3..a62bb708f 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/VariablesManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/VariablesManager.java @@ -18,7 +18,7 @@ package org.apache.hugegraph.driver; import org.apache.hugegraph.api.variables.VariablesAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import java.util.Map; @@ -26,7 +26,7 @@ public class VariablesManager { private VariablesAPI variablesAPI; - public VariablesManager(OkhttpOkhttpRestClient client, String graph) { + public VariablesManager(RestClient client, String graph) { this.variablesAPI = new VariablesAPI(client, graph); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/VersionManager.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/VersionManager.java index ad10773ce..f5283ca68 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/VersionManager.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/VersionManager.java @@ -19,13 +19,13 @@ import org.apache.hugegraph.api.version.VersionAPI; import org.apache.hugegraph.structure.version.Versions; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; public class VersionManager { private VersionAPI versionAPI; - public VersionManager(OkhttpOkhttpRestClient client) { + public VersionManager(RestClient client) { this.versionAPI = new VersionAPI(client); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractOkhttpOkhttpRestClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpAbstractRestClient.java similarity index 89% rename from hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractOkhttpOkhttpRestClient.java rename to hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpAbstractRestClient.java index b993aef4d..9c8532e9f 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/AbstractOkhttpOkhttpRestClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpAbstractRestClient.java @@ -36,33 +36,33 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -public abstract class AbstractOkhttpOkhttpRestClient implements OkhttpRestClient { +public abstract class OkhttpAbstractRestClient implements OkhttpRestClient { private OkHttpClient client; private String baseUrl; - public AbstractOkhttpOkhttpRestClient(String url, int timeout) { + public OkhttpAbstractRestClient(String url, int timeout) { this(url, OkhttpConfig.builder() .timeout(timeout) .build()); } - public AbstractOkhttpOkhttpRestClient(String url, String user, String password, - Integer timeout) { + public OkhttpAbstractRestClient(String url, String user, String password, + Integer timeout) { this(url, OkhttpConfig.builder() .user(user).password(password) .timeout(timeout) .build()); } - public AbstractOkhttpOkhttpRestClient(String url, int timeout, - int maxTotal, int maxPerRoute) { + public OkhttpAbstractRestClient(String url, int timeout, + int maxTotal, int maxPerRoute) { this(url, null, null, timeout, maxTotal, maxPerRoute); } - public AbstractOkhttpOkhttpRestClient(String url, int timeout, int idleTime, - int maxTotal, int maxPerRoute) { + public OkhttpAbstractRestClient(String url, int timeout, int idleTime, + int maxTotal, int maxPerRoute) { this(url, OkhttpConfig.builder() .idleTime(idleTime) .timeout(timeout) @@ -71,8 +71,8 @@ public AbstractOkhttpOkhttpRestClient(String url, int timeout, int idleTime, .build()); } - public AbstractOkhttpOkhttpRestClient(String url, String user, String password, - int timeout, int maxTotal, int maxPerRoute) { + public OkhttpAbstractRestClient(String url, String user, String password, + int timeout, int maxTotal, int maxPerRoute) { this(url, OkhttpConfig.builder() .user(user).password(password) .timeout(timeout) @@ -81,10 +81,10 @@ public AbstractOkhttpOkhttpRestClient(String url, String user, String password, .build()); } - public AbstractOkhttpOkhttpRestClient(String url, String user, String password, - int timeout, int maxTotal, int maxPerRoute, - String trustStoreFile, - String trustStorePassword) { + public OkhttpAbstractRestClient(String url, String user, String password, + int timeout, int maxTotal, int maxPerRoute, + String trustStoreFile, + String trustStorePassword) { this(url, OkhttpConfig.builder() .user(user).password(password) .timeout(timeout) @@ -95,15 +95,15 @@ public AbstractOkhttpOkhttpRestClient(String url, String user, String password, .build()); } - public AbstractOkhttpOkhttpRestClient(String url, String token, Integer timeout) { + public OkhttpAbstractRestClient(String url, String token, Integer timeout) { this(url, OkhttpConfig.builder() .token(token) .timeout(timeout) .build()); } - public AbstractOkhttpOkhttpRestClient(String url, String token, Integer timeout, - Integer maxTotal, Integer maxPerRoute) { + public OkhttpAbstractRestClient(String url, String token, Integer timeout, + Integer maxTotal, Integer maxPerRoute) { this(url,OkhttpConfig.builder() .token(token) .timeout(timeout) @@ -112,10 +112,10 @@ public AbstractOkhttpOkhttpRestClient(String url, String token, Integer timeout, .build()); } - public AbstractOkhttpOkhttpRestClient(String url, String token, Integer timeout, - Integer maxTotal, Integer maxPerRoute, - String trustStoreFile, - String trustStorePassword) { + public OkhttpAbstractRestClient(String url, String token, Integer timeout, + Integer maxTotal, Integer maxPerRoute, + String trustStoreFile, + String trustStorePassword) { this(url,OkhttpConfig.builder() .token(token) .timeout(timeout) @@ -126,7 +126,7 @@ public AbstractOkhttpOkhttpRestClient(String url, String token, Integer timeout, .build()); } - public AbstractOkhttpOkhttpRestClient(String url, OkhttpConfig okhttpConfig) { + public OkhttpAbstractRestClient(String url, OkhttpConfig okhttpConfig) { this.baseUrl = url; this.client = getOkhttpClient(okhttpConfig); } diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/api/BaseApiTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/api/BaseApiTest.java index 97e0e0704..37e88622e 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/api/BaseApiTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/api/BaseApiTest.java @@ -33,7 +33,7 @@ import org.apache.hugegraph.api.task.TaskAPI; import org.apache.hugegraph.api.variables.VariablesAPI; import org.apache.hugegraph.api.version.VersionAPI; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.testutil.Assert; import org.apache.hugegraph.util.VersionUtil; import org.junit.AfterClass; @@ -41,7 +41,7 @@ public class BaseApiTest extends BaseClientTest { - protected static OkhttpOkhttpRestClient client; + protected static RestClient client; protected static VersionAPI versionAPI; protected static GraphsAPI graphsAPI; @@ -59,8 +59,8 @@ public class BaseApiTest extends BaseClientTest { protected static TaskAPI taskAPI; protected static RebuildAPI rebuildAPI; - protected static OkhttpOkhttpRestClient initClient() { - client = new OkhttpOkhttpRestClient(BASE_URL, USERNAME, PASSWORD, TIMEOUT); + protected static RestClient initClient() { + client = new RestClient(BASE_URL, USERNAME, PASSWORD, TIMEOUT); return client; } @@ -101,7 +101,7 @@ public static void clear() throws Exception { BaseClientTest.clear(); } - protected OkhttpOkhttpRestClient client() { + protected RestClient client() { return client; } diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/LogoutApiTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/LogoutApiTest.java index 4b479cbe8..0652fb3b4 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/LogoutApiTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/LogoutApiTest.java @@ -19,7 +19,7 @@ import java.util.List; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.ServerException; import org.apache.hugegraph.structure.auth.Login; import org.apache.hugegraph.structure.auth.LoginResult; @@ -77,7 +77,7 @@ public void testLogout() { }); String token = result.token(); - OkhttpOkhttpRestClient client = Whitebox.getInternalState(logoutAPI, "client"); + RestClient client = Whitebox.getInternalState(logoutAPI, "client"); client.setAuthContext("Bearer " + token); logoutAPI.logout(); } diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/TokenApiTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/TokenApiTest.java index 689ebaf6e..8ac29e144 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/TokenApiTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/TokenApiTest.java @@ -19,7 +19,7 @@ import java.util.List; -import org.apache.hugegraph.client.OkhttpOkhttpRestClient; +import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.ServerException; import org.apache.hugegraph.structure.auth.Login; import org.apache.hugegraph.structure.auth.LoginResult; @@ -80,7 +80,7 @@ public void testVerify() { }); String token = result.token(); - OkhttpOkhttpRestClient client = Whitebox.getInternalState(tokenAPI, "client"); + RestClient client = Whitebox.getInternalState(tokenAPI, "client"); client.setAuthContext("Bearer " + token); TokenPayload payload = tokenAPI.verifyToken(); @@ -94,7 +94,7 @@ public void testVerify() { Assert.assertContains("Invalid token", e.getMessage()); }); - OkhttpOkhttpRestClient client2 = Whitebox.getInternalState(logoutAPI, "client"); + RestClient client2 = Whitebox.getInternalState(logoutAPI, "client"); Assert.assertThrows(ServerException.class, () -> { logoutAPI.logout(); }, e -> { From aff445517c269b4e4afd4a047869f03ed603a344 Mon Sep 17 00:00:00 2001 From: tianzy Date: Fri, 18 Aug 2023 01:22:09 +0800 Subject: [PATCH 18/53] add workflow_dispatch --- .github/workflows/codeql-analysis.yml | 1 + .github/workflows/license-checker.yml | 1 + .github/workflows/tools-ci.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 5499c6db2..1e2f191ac 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -12,6 +12,7 @@ name: "CodeQL" on: + workflow_dispatch: push: branches: [ master, release-* ] pull_request: diff --git a/.github/workflows/license-checker.yml b/.github/workflows/license-checker.yml index 540de04e6..33f949e41 100644 --- a/.github/workflows/license-checker.yml +++ b/.github/workflows/license-checker.yml @@ -20,6 +20,7 @@ name: "license checker" on: + workflow_dispatch: push: branches: - master diff --git a/.github/workflows/tools-ci.yml b/.github/workflows/tools-ci.yml index 5028048cc..17d4f66fe 100644 --- a/.github/workflows/tools-ci.yml +++ b/.github/workflows/tools-ci.yml @@ -1,5 +1,6 @@ name: "hugegraph-tools-ci" on: + workflow_dispatch: push: branches: - master From d3d3dafb5ce287c9240f4ebe89ee2d99bd361459 Mon Sep 17 00:00:00 2001 From: tianzy Date: Fri, 18 Aug 2023 01:40:48 +0800 Subject: [PATCH 19/53] fix licence dependency check error --- .../scripts/dependency/known-dependencies.txt | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/hugegraph-dist/scripts/dependency/known-dependencies.txt b/hugegraph-dist/scripts/dependency/known-dependencies.txt index d849580f1..0783575f4 100644 --- a/hugegraph-dist/scripts/dependency/known-dependencies.txt +++ b/hugegraph-dist/scripts/dependency/known-dependencies.txt @@ -11,7 +11,6 @@ annotations-13.0.jar ant-1.9.1.jar ant-launcher-1.9.1.jar antlr-runtime-3.5.2.jar -aopalliance-repackaged-3.0.1.jar apache-curator-2.12.0.pom arrow-format-0.8.0.jar arrow-format-2.0.0.jar @@ -113,9 +112,6 @@ hive-storage-api-2.7.0.jar hive-storage-api-2.7.2.jar hive-upgrade-acid-3.1.3.jar hive-vector-code-gen-3.1.3.jar -hk2-api-3.0.1.jar -hk2-locator-3.0.1.jar -hk2-utils-3.0.1.jar hppc-0.7.2.jar htrace-core4-4.1.0-incubating.jar htrace-core4-4.2.0-incubating.jar @@ -139,9 +135,10 @@ jackson-module-jaxb-annotations-2.12.3.jar jackson-module-parameter-names-2.12.3.jar jakarta.activation-2.0.1.jar jakarta.activation-api-1.2.1.jar -jakarta.annotation-api-2.0.0.jar -jakarta.inject-api-2.0.0.jar -jakarta.ws.rs-api-3.0.0.jar +jersey-container-servlet-core-2.25.1.jar +jersey-container-servlet-core-2.27.jar +javax.inject-2.5.0-b32.jar +javax.inject-2.5.0-b42.jar jakarta.xml.bind-api-2.3.2.jar jakarta.xml.bind-api-4.0.0-RC2.jar jamon-runtime-2.4.1.jar @@ -166,13 +163,6 @@ jcip-annotations-1.0-1.jar jcodings-1.0.18.jar jcommander-1.72.jar jcommander-1.78.jar -jersey-apache-connector-3.0.3.jar -jersey-client-3.0.3.jar -jersey-common-3.0.3.jar -jersey-container-servlet-core-3.0.3.jar -jersey-entity-filtering-3.0.3.jar -jersey-hk2-3.0.3.jar -jersey-media-json-jackson-3.0.3.jar jetty-client-9.4.33.v20201020.jar jetty-client-9.4.40.v20210413.jar jetty-http-9.4.19.v20190610.jar @@ -281,7 +271,6 @@ orc-core-1.5.8.jar orc-core-1.6.14.jar orc-shims-1.5.8.jar orc-shims-1.6.14.jar -osgi-resource-locator-1.0.3.jar ow2-asm-6.2.jar paranamer-2.3.jar postgresql-42.2.6.jar From 389431a275275f779c4c445d14458ad2efa99993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Wed, 22 Nov 2023 21:02:01 +0800 Subject: [PATCH 20/53] feat: merge request --- .../org/apache/hugegraph/exception/ServerException.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java index 3159ab7a0..995d372b6 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java @@ -19,8 +19,11 @@ import java.util.Map; -import okhttp3.Response; import org.apache.hugegraph.rest.OkhttpRestResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import okhttp3.Response; public class ServerException extends RuntimeException { @@ -42,9 +45,9 @@ public class ServerException extends RuntimeException { private Object trace; public static ServerException fromResponse(Response response) { - RestResult rs = new RestResult(response); + OkhttpRestResult rs = new OkhttpRestResult(response); ServerException exception = new ServerException(rs.content()); - exception.status(response.getStatus()); + exception.status(response.code()); try { @SuppressWarnings("unchecked") Map json = rs.readObject(Map.class); From 93f83ab5b81cf1fff18037111d3ae6434e92945f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Wed, 22 Nov 2023 21:35:20 +0800 Subject: [PATCH 21/53] chore(ci): add stage profile settings --- .github/configs/settings.xml | 60 ++++++++++++++++++++++++ .github/workflows/client-ci.yml | 7 +++ .github/workflows/codeql-analysis.yml | 8 ++++ .github/workflows/hubble-ci.yml | 7 +++ .github/workflows/license-checker.yml | 7 +++ .github/workflows/loader-ci.yml | 7 +++ .github/workflows/spark-connector-ci.yml | 7 +++ .github/workflows/tools-ci.yml | 6 +++ pom.xml | 11 +++++ 9 files changed, 120 insertions(+) create mode 100644 .github/configs/settings.xml diff --git a/.github/configs/settings.xml b/.github/configs/settings.xml new file mode 100644 index 000000000..294ded1cb --- /dev/null +++ b/.github/configs/settings.xml @@ -0,0 +1,60 @@ + + + + + + github + ${env.GITHUB_ACTOR} + ${env.GITHUB_TOKEN} + + + + + + local-repo + + + central + https://repo.maven.apache.org/maven2 + + true + + + false + + + + staged-releases + https://repository.apache.org/content/groups/staging/ + + + + + staged-releases + https://repository.apache.org/content/groups/staging/ + + + + + + + local-repo + + diff --git a/.github/workflows/client-ci.yml b/.github/workflows/client-ci.yml index 15488ae09..b577a920f 100644 --- a/.github/workflows/client-ci.yml +++ b/.github/workflows/client-ci.yml @@ -21,6 +21,7 @@ jobs: client-ci: runs-on: ubuntu-20.04 env: + USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-client/assembly/travis COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314 strategy: @@ -41,6 +42,12 @@ jobs: key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 + - name: Use staged maven repo + if: ${{ env.USE_STAGE == 'true' }} + run: | + cp $HOME/.m2/settings.xml /tmp/settings.xml + mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml + - name: Checkout uses: actions/checkout@v3 with: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index d709ec895..838b4c5f6 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -20,6 +20,8 @@ on: jobs: analyze: + env: + USE_STAGE: 'true' # Whether to include the stage repository. name: Analyze runs-on: ubuntu-latest permissions: @@ -42,6 +44,12 @@ jobs: with: distribution: 'zulu' java-version: '8' + + - name: use staged maven repo settings + if: ${{ env.USE_STAGE == 'true' }} + run: | + cp $HOME/.m2/settings.xml /tmp/settings.xml + mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml - name: Use Node.js 16 uses: actions/setup-node@v3 diff --git a/.github/workflows/hubble-ci.yml b/.github/workflows/hubble-ci.yml index 007b45f6d..cbbdfcca7 100644 --- a/.github/workflows/hubble-ci.yml +++ b/.github/workflows/hubble-ci.yml @@ -29,6 +29,7 @@ jobs: hubble-ci: runs-on: ubuntu-latest env: + USE_STAGE: 'true' # Whether to include the stage repository. STATIC_DIR: hugegraph-hubble/hubble-dist/assembly/static steps: - name: Install JDK 11 @@ -49,6 +50,12 @@ jobs: restore-keys: | ${{ runner.os }}-maven- + - name: use staged maven repo settings + if: ${{ env.USE_STAGE == 'true' }} + run: | + cp $HOME/.m2/settings.xml /tmp/settings.xml + mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml + - name: Get Yarn path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" diff --git a/.github/workflows/license-checker.yml b/.github/workflows/license-checker.yml index 540de04e6..16ccea5ff 100644 --- a/.github/workflows/license-checker.yml +++ b/.github/workflows/license-checker.yml @@ -35,6 +35,7 @@ jobs: - name: Check License Header uses: apache/skywalking-eyes@main env: + SE_STAGE: 'true' # Whether to include the stage repository. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: log: info @@ -45,6 +46,12 @@ jobs: java-version: '11' distribution: 'adopt' + - name: use staged maven repo settings + if: ${{ env.USE_STAGE == 'true' }} + run: | + cp $HOME/.m2/settings.xml /tmp/settings.xml + mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml + - name: Use Node.js 16 uses: actions/setup-node@v3 with: diff --git a/.github/workflows/loader-ci.yml b/.github/workflows/loader-ci.yml index 0a7db5224..6fdd29ffe 100644 --- a/.github/workflows/loader-ci.yml +++ b/.github/workflows/loader-ci.yml @@ -22,6 +22,7 @@ jobs: loader-ci: runs-on: ubuntu-latest env: + SE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-loader/assembly/travis STATIC_DIR: hugegraph-loader/assembly/static COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314 @@ -42,6 +43,12 @@ jobs: key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 + - name: use staged maven repo settings + if: ${{ env.USE_STAGE == 'true' }} + run: | + cp $HOME/.m2/settings.xml /tmp/settings.xml + mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml + - name: Checkout uses: actions/checkout@v3 with: diff --git a/.github/workflows/spark-connector-ci.yml b/.github/workflows/spark-connector-ci.yml index efa4639be..4637a7e46 100644 --- a/.github/workflows/spark-connector-ci.yml +++ b/.github/workflows/spark-connector-ci.yml @@ -22,6 +22,7 @@ jobs: spark-connector-ci: runs-on: ubuntu-latest env: + SE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-spark-connector/assembly/travis VERSION_ID: 1.0.0 steps: @@ -38,6 +39,12 @@ jobs: key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 + - name: use staged maven repo settings + if: ${{ env.USE_STAGE == 'true' }} + run: | + cp $HOME/.m2/settings.xml /tmp/settings.xml + mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml + - name: Checkout uses: actions/checkout@v4 with: diff --git a/.github/workflows/tools-ci.yml b/.github/workflows/tools-ci.yml index 5028048cc..d88e310cc 100644 --- a/.github/workflows/tools-ci.yml +++ b/.github/workflows/tools-ci.yml @@ -21,6 +21,7 @@ jobs: tools-ci: runs-on: ubuntu-latest env: + SE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-tools/assembly/travis # TODO: could we use one param to unify it? or use a action template (could use one ci file) COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314 @@ -36,6 +37,11 @@ jobs: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 + - name: use staged maven repo settings + if: ${{ env.USE_STAGE == 'true' }} + run: | + cp $HOME/.m2/settings.xml /tmp/settings.xml + mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml - name: Checkout uses: actions/checkout@v3 with: diff --git a/pom.xml b/pom.xml index 7eb4cb500..00d1ecd4f 100644 --- a/pom.xml +++ b/pom.xml @@ -375,6 +375,17 @@ + + + + stage + + + staged-releases + https://repository.apache.org/content/groups/staging/ + + + From 9c5232093c5bb8d124847eb062cecbcd48780025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Wed, 22 Nov 2023 22:09:11 +0800 Subject: [PATCH 22/53] update common version and fix code --- .../apache/hugegraph/api/auth/AccessAPI.java | 10 +- .../apache/hugegraph/api/auth/BelongAPI.java | 10 +- .../apache/hugegraph/api/auth/GroupAPI.java | 10 +- .../apache/hugegraph/api/auth/LoginAPI.java | 4 +- .../apache/hugegraph/api/auth/ProjectAPI.java | 14 +- .../apache/hugegraph/api/auth/TargetAPI.java | 10 +- .../apache/hugegraph/api/auth/TokenAPI.java | 4 +- .../apache/hugegraph/api/auth/UserAPI.java | 12 +- .../apache/hugegraph/api/graph/EdgeAPI.java | 26 +- .../apache/hugegraph/api/graph/VertexAPI.java | 33 +- .../hugegraph/api/graphs/GraphsAPI.java | 17 +- .../hugegraph/api/gremlin/CypherAPI.java | 4 +- .../hugegraph/api/gremlin/GremlinAPI.java | 4 +- .../hugegraph/api/job/GremlinJobAPI.java | 4 +- .../apache/hugegraph/api/job/RebuildAPI.java | 4 +- .../hugegraph/api/metrics/MetricsAPI.java | 8 +- .../hugegraph/api/schema/EdgeLabelAPI.java | 16 +- .../hugegraph/api/schema/IndexLabelAPI.java | 16 +- .../hugegraph/api/schema/PropertyKeyAPI.java | 18 +- .../hugegraph/api/schema/SchemaAPI.java | 4 +- .../hugegraph/api/schema/VertexLabelAPI.java | 16 +- .../apache/hugegraph/api/task/TaskAPI.java | 12 +- .../api/traverser/AllShortestPathsAPI.java | 4 +- .../hugegraph/api/traverser/CountAPI.java | 4 +- .../api/traverser/CrosspointsAPI.java | 4 +- .../traverser/CustomizedCrosspointsAPI.java | 4 +- .../api/traverser/CustomizedPathsAPI.java | 4 +- .../hugegraph/api/traverser/EdgesAPI.java | 8 +- .../api/traverser/FusiformSimilarityAPI.java | 4 +- .../api/traverser/JaccardSimilarityAPI.java | 6 +- .../hugegraph/api/traverser/KneighborAPI.java | 6 +- .../hugegraph/api/traverser/KoutAPI.java | 6 +- .../traverser/MultiNodeShortestPathAPI.java | 4 +- .../api/traverser/NeighborRankAPI.java | 4 +- .../hugegraph/api/traverser/PathsAPI.java | 6 +- .../api/traverser/PersonalRankAPI.java | 4 +- .../hugegraph/api/traverser/RaysAPI.java | 4 +- .../hugegraph/api/traverser/RingsAPI.java | 4 +- .../api/traverser/SameNeighborsAPI.java | 4 +- .../api/traverser/ShortestPathAPI.java | 4 +- .../SingleSourceShortestPathAPI.java | 4 +- .../api/traverser/TemplatePathsAPI.java | 4 +- .../hugegraph/api/traverser/VerticesAPI.java | 8 +- .../traverser/WeightedShortestPathAPI.java | 4 +- .../hugegraph/api/variables/VariablesAPI.java | 8 +- .../hugegraph/api/version/VersionAPI.java | 4 +- .../apache/hugegraph/client/RestClient.java | 8 +- .../hugegraph/exception/ServerException.java | 4 +- .../rest/OkhttpAbstractRestClient.java | 449 ------------------ .../rest/OkhttpBasicAuthInterceptor.java | 45 -- .../apache/hugegraph/rest/OkhttpConfig.java | 37 -- .../hugegraph/rest/OkhttpRestClient.java | 64 --- .../hugegraph/rest/OkhttpRestResult.java | 118 ----- .../rest/OkhttpTokenInterceptor.java | 44 -- .../apache/hugegraph/unit/RestResultTest.java | 80 ++-- hugegraph-spark-connector/pom.xml | 56 +-- pom.xml | 20 +- 57 files changed, 255 insertions(+), 1042 deletions(-) delete mode 100644 hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpAbstractRestClient.java delete mode 100644 hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpBasicAuthInterceptor.java delete mode 100644 hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpConfig.java delete mode 100644 hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpRestClient.java delete mode 100644 hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpRestResult.java delete mode 100644 hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpTokenInterceptor.java diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AccessAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AccessAPI.java index ad49eb267..78a32cbed 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AccessAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/AccessAPI.java @@ -22,7 +22,7 @@ import java.util.Map; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.auth.Access; import org.apache.hugegraph.structure.constant.HugeType; @@ -38,12 +38,12 @@ protected String type() { } public Access create(Access access) { - OkhttpRestResult result = this.client.post(this.path(), access); + RestResult result = this.client.post(this.path(), access); return result.readObject(Access.class); } public Access get(Object id) { - OkhttpRestResult result = this.client.get(this.path(), formatRelationId(id)); + RestResult result = this.client.get(this.path(), formatRelationId(id)); return result.readObject(Access.class); } @@ -53,13 +53,13 @@ public List list(Object group, Object target, int limit) { params.put("limit", limit); params.put("group", formatEntityId(group)); params.put("target", formatEntityId(target)); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Access.class); } public Access update(Access access) { String id = formatRelationId(access.id()); - OkhttpRestResult result = this.client.put(this.path(), id, access); + RestResult result = this.client.put(this.path(), id, access); return result.readObject(Access.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/BelongAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/BelongAPI.java index 495fc0626..bcf18d9d9 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/BelongAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/BelongAPI.java @@ -22,7 +22,7 @@ import java.util.Map; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.auth.Belong; import org.apache.hugegraph.structure.constant.HugeType; @@ -38,12 +38,12 @@ protected String type() { } public Belong create(Belong belong) { - OkhttpRestResult result = this.client.post(this.path(), belong); + RestResult result = this.client.post(this.path(), belong); return result.readObject(Belong.class); } public Belong get(Object id) { - OkhttpRestResult result = this.client.get(this.path(), formatRelationId(id)); + RestResult result = this.client.get(this.path(), formatRelationId(id)); return result.readObject(Belong.class); } @@ -53,13 +53,13 @@ public List list(Object user, Object group, int limit) { params.put("limit", limit); params.put("user", formatEntityId(user)); params.put("group", formatEntityId(group)); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Belong.class); } public Belong update(Belong belong) { String id = formatRelationId(belong.id()); - OkhttpRestResult result = this.client.put(this.path(), id, belong); + RestResult result = this.client.put(this.path(), id, belong); return result.readObject(Belong.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/GroupAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/GroupAPI.java index cfd6f36ad..416f941db 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/GroupAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/GroupAPI.java @@ -21,7 +21,7 @@ import java.util.Map; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.auth.Group; import org.apache.hugegraph.structure.constant.HugeType; @@ -39,25 +39,25 @@ protected String type() { } public Group create(Group group) { - OkhttpRestResult result = this.client.post(this.path(), group); + RestResult result = this.client.post(this.path(), group); return result.readObject(Group.class); } public Group get(Object id) { - OkhttpRestResult result = this.client.get(this.path(), formatEntityId(id)); + RestResult result = this.client.get(this.path(), formatEntityId(id)); return result.readObject(Group.class); } public List list(int limit) { checkLimit(limit, "Limit"); Map params = ImmutableMap.of("limit", limit); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Group.class); } public Group update(Group group) { String id = formatEntityId(group.id()); - OkhttpRestResult result = this.client.put(this.path(), id, group); + RestResult result = this.client.put(this.path(), id, group); return result.readObject(Group.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LoginAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LoginAPI.java index 9d74af0b5..e7996e689 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LoginAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/LoginAPI.java @@ -18,7 +18,7 @@ package org.apache.hugegraph.api.auth; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.auth.Login; import org.apache.hugegraph.structure.auth.LoginResult; import org.apache.hugegraph.structure.constant.HugeType; @@ -35,7 +35,7 @@ protected String type() { } public LoginResult login(Login login) { - OkhttpRestResult result = this.client.post(this.path(), login); + RestResult result = this.client.post(this.path(), login); return result.readObject(LoginResult.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/ProjectAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/ProjectAPI.java index af9eefcf0..dbf9248f7 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/ProjectAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/ProjectAPI.java @@ -22,7 +22,7 @@ import java.util.Set; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.auth.Project; import org.apache.hugegraph.structure.constant.HugeType; @@ -43,25 +43,25 @@ protected String type() { } public Project create(Project project) { - OkhttpRestResult result = this.client.post(this.path(), project); + RestResult result = this.client.post(this.path(), project); return result.readObject(Project.class); } public Project get(Object id) { - OkhttpRestResult result = this.client.get(this.path(), formatEntityId(id)); + RestResult result = this.client.get(this.path(), formatEntityId(id)); return result.readObject(Project.class); } public List list(long limit) { checkLimit(limit, "Limit"); Map params = ImmutableMap.of("limit", limit); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Project.class); } public Project update(Project project) { String id = formatEntityId(project.id()); - OkhttpRestResult result = this.client.put(this.path(), id, project); + RestResult result = this.client.put(this.path(), id, project); return result.readObject(Project.class); } @@ -72,7 +72,7 @@ public void delete(Object id) { public Project addGraphs(Object projectId, Set graphs) { Project project = new Project(); project.graphs(graphs); - OkhttpRestResult result = this.client.put(this.path(), + RestResult result = this.client.put(this.path(), formatEntityId(projectId), project, ImmutableMap.of("action", @@ -83,7 +83,7 @@ public Project addGraphs(Object projectId, Set graphs) { public Project removeGraphs(Object projectId, Set graphs) { Project project = new Project(); project.graphs(graphs); - OkhttpRestResult result = this.client.put(this.path(), + RestResult result = this.client.put(this.path(), formatEntityId(projectId), project, ImmutableMap.of("action", diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TargetAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TargetAPI.java index 488aa3443..2e3687d96 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TargetAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TargetAPI.java @@ -21,7 +21,7 @@ import java.util.Map; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.auth.Target; import org.apache.hugegraph.structure.constant.HugeType; @@ -39,25 +39,25 @@ protected String type() { } public Target create(Target target) { - OkhttpRestResult result = this.client.post(this.path(), target); + RestResult result = this.client.post(this.path(), target); return result.readObject(Target.class); } public Target get(Object id) { - OkhttpRestResult result = this.client.get(this.path(), formatEntityId(id)); + RestResult result = this.client.get(this.path(), formatEntityId(id)); return result.readObject(Target.class); } public List list(int limit) { checkLimit(limit, "Limit"); Map params = ImmutableMap.of("limit", limit); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Target.class); } public Target update(Target target) { String id = formatEntityId(target.id()); - OkhttpRestResult result = this.client.put(this.path(), id, target); + RestResult result = this.client.put(this.path(), id, target); return result.readObject(Target.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TokenAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TokenAPI.java index d9605e77e..58b3b73a1 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TokenAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/TokenAPI.java @@ -18,7 +18,7 @@ package org.apache.hugegraph.api.auth; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.auth.TokenPayload; import org.apache.hugegraph.structure.constant.HugeType; @@ -34,7 +34,7 @@ protected String type() { } public TokenPayload verifyToken() { - OkhttpRestResult result = this.client.get(this.path()); + RestResult result = this.client.get(this.path()); return result.readObject(TokenPayload.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java index 99c01ef13..5b1ea3254 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java @@ -21,7 +21,7 @@ import java.util.Map; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.auth.User; import org.apache.hugegraph.structure.auth.User.UserRole; import org.apache.hugegraph.structure.constant.HugeType; @@ -40,12 +40,12 @@ protected String type() { } public User create(User user) { - OkhttpRestResult result = this.client.post(this.path(), user); + RestResult result = this.client.post(this.path(), user); return result.readObject(User.class); } public User get(Object id) { - OkhttpRestResult result = this.client.get(this.path(), formatEntityId(id)); + RestResult result = this.client.get(this.path(), formatEntityId(id)); return result.readObject(User.class); } @@ -53,20 +53,20 @@ public UserRole getUserRole(Object id) { // String idEncoded = RestClient.encode(formatEntityId(id)); String idEncoded = formatEntityId(id); String path = String.join("/", this.path(), idEncoded, "role"); - OkhttpRestResult result = this.client.get(path); + RestResult result = this.client.get(path); return result.readObject(UserRole.class); } public List list(int limit) { checkLimit(limit, "Limit"); Map params = ImmutableMap.of("limit", limit); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(this.type(), User.class); } public User update(User user) { String id = formatEntityId(user.id()); - OkhttpRestResult result = this.client.put(this.path(), id, user); + RestResult result = this.client.put(this.path(), id, user); return result.readObject(User.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java index 45d14f107..64ef0b312 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java @@ -24,7 +24,8 @@ import okhttp3.Headers; import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.NotAllCreatedException; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestHeaders; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.graph.BatchEdgeRequest; @@ -45,17 +46,15 @@ protected String type() { } public Edge create(Edge edge) { - OkhttpRestResult result = this.client.post(this.path(), edge); + RestResult result = this.client.post(this.path(), edge); return result.readObject(Edge.class); } public List create(List edges, boolean checkVertex) { -// MultivaluedHashMap headers = new MultivaluedHashMap<>(); -// headers.putSingle("Content-Encoding", BATCH_ENCODING); - Headers headers = new Headers.Builder().add("Content-Encoding", BATCH_ENCODING).build(); + RestHeaders headers = new RestHeaders().add(RestHeaders.CONTENT_ENCODING, BATCH_ENCODING); Map params = ImmutableMap.of("check_vertex", checkVertex); - OkhttpRestResult result = this.client.post(this.batchPath(), edges, + RestResult result = this.client.post(this.batchPath(), edges, headers, params); List ids = result.readList(String.class); if (edges.size() != ids.size()) { @@ -68,30 +67,27 @@ public List create(List edges, boolean checkVertex) { public List update(BatchEdgeRequest request) { this.client.checkApiVersion("0.45", "batch property update"); -// MultivaluedHashMap headers = new MultivaluedHashMap<>(); -// headers.putSingle("Content-Encoding", BATCH_ENCODING); - Headers headers = new Headers.Builder().add("Content-Encoding", BATCH_ENCODING).build(); - OkhttpRestResult result = this.client.put(this.batchPath(), null, - request, headers); + RestHeaders headers = new RestHeaders().add(RestHeaders.CONTENT_ENCODING, BATCH_ENCODING); + RestResult result = this.client.put(this.batchPath(), null, request, headers); return result.readList(this.type(), Edge.class); } public Edge append(Edge edge) { String id = edge.id(); Map params = ImmutableMap.of("action", "append"); - OkhttpRestResult result = this.client.put(this.path(), id, edge, params); + RestResult result = this.client.put(this.path(), id, edge, params); return result.readObject(Edge.class); } public Edge eliminate(Edge edge) { String id = edge.id(); Map params = ImmutableMap.of("action", "eliminate"); - OkhttpRestResult result = this.client.put(this.path(), id, edge, params); + RestResult result = this.client.put(this.path(), id, edge, params); return result.readObject(Edge.class); } public Edge get(String id) { - OkhttpRestResult result = this.client.get(this.path(), id); + RestResult result = this.client.get(this.path(), id); return result.readObject(Edge.class); } @@ -122,7 +118,7 @@ public Edges list(Object vertexId, Direction direction, String label, params.put("offset", offset); params.put("limit", limit); params.put("page", page); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readObject(Edges.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java index 2f35a36b1..61ebc1461 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java @@ -22,7 +22,8 @@ import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.InvalidResponseException; import org.apache.hugegraph.exception.NotAllCreatedException; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestHeaders; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.graph.BatchOlapPropertyRequest; import org.apache.hugegraph.structure.graph.BatchVertexRequest; @@ -45,16 +46,13 @@ protected String type() { } public Vertex create(Vertex vertex) { - OkhttpRestResult result = this.client.post(this.path(), vertex); + RestResult result = this.client.post(this.path(), vertex); return result.readObject(Vertex.class); } public List create(List vertices) { -// MultivaluedHashMap headers = new MultivaluedHashMap<>(); -// headers.putSingle("Content-Encoding", BATCH_ENCODING); - Headers headers = new Headers.Builder().add("Content-Encoding", BATCH_ENCODING).build(); - OkhttpRestResult result = this.client.post(this.batchPath(), vertices, - headers); + RestHeaders headers = new RestHeaders().add(RestHeaders.CONTENT_ENCODING, BATCH_ENCODING); + RestResult result = this.client.post(this.batchPath(), vertices, headers); List ids = result.readList(Object.class); if (vertices.size() != ids.size()) { throw new NotAllCreatedException("Not all vertices are successfully created, " + @@ -66,21 +64,16 @@ public List create(List vertices) { public List update(BatchVertexRequest request) { this.client.checkApiVersion("0.45", "batch property update"); -// MultivaluedHashMap headers = new MultivaluedHashMap<>(); -// headers.putSingle("Content-Encoding", BATCH_ENCODING); - Headers headers = new Headers.Builder().add("Content-Encoding", BATCH_ENCODING).build(); - OkhttpRestResult result = this.client.put(this.batchPath(), null, - request, headers); + RestHeaders headers = new RestHeaders().add(RestHeaders.CONTENT_ENCODING, BATCH_ENCODING); + RestResult result = this.client.put(this.batchPath(), null, request, headers); return result.readList(this.type(), Vertex.class); } public int update(BatchOlapPropertyRequest request) { this.client.checkApiVersion("0.59", "olap property batch update"); -// MultivaluedHashMap headers = new MultivaluedHashMap<>(); -// headers.putSingle("Content-Encoding", BATCH_ENCODING); - Headers headers = new Headers.Builder().add("Content-Encoding", BATCH_ENCODING).build(); + RestHeaders headers = new RestHeaders().add(RestHeaders.CONTENT_ENCODING, BATCH_ENCODING); String path = String.join("/", this.path(), "olap/batch"); - OkhttpRestResult result = this.client.put(path, null, request, headers); + RestResult result = this.client.put(path, null, request, headers); Object size = result.readObject(Map.class).get("size"); if (!(size instanceof Integer)) { throw new InvalidResponseException("The 'size' in response must be int, " + @@ -92,20 +85,20 @@ public int update(BatchOlapPropertyRequest request) { public Vertex append(Vertex vertex) { String id = formatVertexId(vertex.id()); Map params = ImmutableMap.of("action", "append"); - OkhttpRestResult result = this.client.put(this.path(), id, vertex, params); + RestResult result = this.client.put(this.path(), id, vertex, params); return result.readObject(Vertex.class); } public Vertex eliminate(Vertex vertex) { String id = formatVertexId(vertex.id()); Map params = ImmutableMap.of("action", "eliminate"); - OkhttpRestResult result = this.client.put(this.path(), id, vertex, params); + RestResult result = this.client.put(this.path(), id, vertex, params); return result.readObject(Vertex.class); } public Vertex get(Object id) { String vertexId = formatVertexId(id); - OkhttpRestResult result = this.client.get(this.path(), vertexId); + RestResult result = this.client.get(this.path(), vertexId); return result.readObject(Vertex.class); } @@ -130,7 +123,7 @@ public Vertices list(String label, Map properties, params.put("offset", offset); params.put("limit", limit); params.put("page", page); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readObject(Vertices.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java index c6842430a..851153cad 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java @@ -23,7 +23,8 @@ import org.apache.hugegraph.api.API; import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.InvalidResponseException; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestHeaders; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.GraphMode; import org.apache.hugegraph.structure.constant.GraphReadMode; import org.apache.hugegraph.structure.constant.HugeType; @@ -54,26 +55,24 @@ protected String type() { public Map create(String name, String cloneGraphName, String configText) { this.client.checkApiVersion("0.67", "dynamic graph add"); -// MultivaluedHashMap headers = new MultivaluedHashMap<>(); -// headers.add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN); - Headers headers = new Headers.Builder().add("Content-Type", "text/plain").build(); + RestHeaders headers = new RestHeaders().add(RestHeaders.CONTENT_TYPE, "text/plain"); Map params = null; if (StringUtils.isNotEmpty(cloneGraphName)) { params = ImmutableMap.of("clone_graph_name", cloneGraphName); } - OkhttpRestResult result = this.client.post(joinPath(this.path(), name), + RestResult result = this.client.post(joinPath(this.path(), name), configText, headers, params); return result.readObject(Map.class); } @SuppressWarnings("unchecked") public Map get(String name) { - OkhttpRestResult result = this.client.get(this.path(), name); + RestResult result = this.client.get(this.path(), name); return result.readObject(Map.class); } public List list() { - OkhttpRestResult result = this.client.get(this.path()); + RestResult result = this.client.get(this.path()); return result.readList(this.type(), String.class); } @@ -95,7 +94,7 @@ public void mode(String graph, GraphMode mode) { } public GraphMode mode(String graph) { - OkhttpRestResult result = this.client.get(joinPath(this.path(), graph), MODE); + RestResult result = this.client.get(joinPath(this.path(), graph), MODE); @SuppressWarnings("unchecked") Map mode = result.readObject(Map.class); String value = mode.get(MODE); @@ -120,7 +119,7 @@ public void readMode(String graph, GraphReadMode readMode) { public GraphReadMode readMode(String graph) { this.client.checkApiVersion("0.59", "graph read mode"); - OkhttpRestResult result = this.client.get(joinPath(this.path(), graph), + RestResult result = this.client.get(joinPath(this.path(), graph), GRAPH_READ_MODE); @SuppressWarnings("unchecked") Map readMode = result.readObject(Map.class); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/CypherAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/CypherAPI.java index 1e441efe9..63cf438b9 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/CypherAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/CypherAPI.java @@ -19,7 +19,7 @@ import org.apache.hugegraph.api.API; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.gremlin.Response; @@ -38,7 +38,7 @@ protected String type() { } public Response post(String cypher) { - OkhttpRestResult result = this.client.post(this.path(), cypher); + RestResult result = this.client.post(this.path(), cypher); return result.readObject(Response.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/GremlinAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/GremlinAPI.java index b16d6092c..31795d193 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/GremlinAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/gremlin/GremlinAPI.java @@ -19,7 +19,7 @@ import org.apache.hugegraph.api.API; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.gremlin.Response; @@ -36,7 +36,7 @@ protected String type() { } public Response post(GremlinRequest request) { - OkhttpRestResult result = this.client.post(this.path(), request); + RestResult result = this.client.post(this.path(), request); return result.readObject(Response.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/GremlinJobAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/GremlinJobAPI.java index 4d6e6b388..36bb720be 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/GremlinJobAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/GremlinJobAPI.java @@ -22,7 +22,7 @@ import org.apache.hugegraph.api.gremlin.GremlinRequest; import org.apache.hugegraph.api.task.TaskAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; public class GremlinJobAPI extends JobAPI { @@ -38,7 +38,7 @@ protected String jobType() { } public long execute(GremlinRequest request) { - OkhttpRestResult result = this.client.post(this.path(), request); + RestResult result = this.client.post(this.path(), request); @SuppressWarnings("unchecked") Map task = result.readObject(Map.class); return TaskAPI.parseTaskId(task); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/RebuildAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/RebuildAPI.java index aae9b574d..d3ea915b0 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/RebuildAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/job/RebuildAPI.java @@ -21,7 +21,7 @@ import org.apache.hugegraph.api.task.TaskAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.SchemaElement; import org.apache.hugegraph.structure.schema.EdgeLabel; import org.apache.hugegraph.structure.schema.IndexLabel; @@ -60,7 +60,7 @@ private long rebuildIndex(SchemaElement element) { "Only VertexLabel, EdgeLabel and IndexLabel support " + "rebuild, but got '%s'", element); String path = String.join(PATH_SPLITOR, this.path(), element.type()); - OkhttpRestResult result = this.client.put(path, element.name(), element); + RestResult result = this.client.put(path, element.name(), element); @SuppressWarnings("unchecked") Map task = result.readObject(Map.class); return TaskAPI.parseTaskId(task); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java index c6388a90f..a4fd226df 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java @@ -22,7 +22,7 @@ import org.apache.hugegraph.util.CommonUtil; import org.apache.hugegraph.api.API; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.HugeType; public class MetricsAPI extends API { @@ -39,7 +39,7 @@ protected String type() { @SuppressWarnings("unchecked") public Map> system() { - OkhttpRestResult result = this.client.get(this.path(), "system"); + RestResult result = this.client.get(this.path(), "system"); Map map = result.readObject(Map.class); CommonUtil.checkMapClass(map, String.class, Map.class); for (Object mapValue : map.values()) { @@ -50,7 +50,7 @@ public Map> system() { @SuppressWarnings("unchecked") public Map> backend() { - OkhttpRestResult result = this.client.get(this.path(), "backend"); + RestResult result = this.client.get(this.path(), "backend"); Map map = result.readObject(Map.class); CommonUtil.checkMapClass(map, String.class, Map.class); for (Object mapValue : map.values()) { @@ -65,7 +65,7 @@ public Map backend(String graph) { @SuppressWarnings("unchecked") public Map> all() { - OkhttpRestResult result = this.client.get(this.path()); + RestResult result = this.client.get(this.path()); Map map = result.readObject(Map.class); CommonUtil.checkMapClass(map, String.class, Map.class); for (Object mapValue : map.values()) { diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/EdgeLabelAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/EdgeLabelAPI.java index 0f88fe9de..08efe67a4 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/EdgeLabelAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/EdgeLabelAPI.java @@ -22,7 +22,7 @@ import org.apache.hugegraph.api.task.TaskAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.SchemaElement; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.schema.EdgeLabel; @@ -43,7 +43,7 @@ protected String type() { public EdgeLabel create(EdgeLabel edgeLabel) { Object el = this.checkCreateOrUpdate(edgeLabel); - OkhttpRestResult result = this.client.post(this.path(), el); + RestResult result = this.client.post(this.path(), el); return result.readObject(EdgeLabel.class); } @@ -51,7 +51,7 @@ public EdgeLabel append(EdgeLabel edgeLabel) { String id = edgeLabel.name(); Map params = ImmutableMap.of("action", "append"); Object el = this.checkCreateOrUpdate(edgeLabel); - OkhttpRestResult result = this.client.put(this.path(), id, el, params); + RestResult result = this.client.put(this.path(), id, el, params); return result.readObject(EdgeLabel.class); } @@ -59,17 +59,17 @@ public EdgeLabel eliminate(EdgeLabel edgeLabel) { String id = edgeLabel.name(); Map params = ImmutableMap.of("action", "eliminate"); Object el = this.checkCreateOrUpdate(edgeLabel); - OkhttpRestResult result = this.client.put(this.path(), id, el, params); + RestResult result = this.client.put(this.path(), id, el, params); return result.readObject(EdgeLabel.class); } public EdgeLabel get(String name) { - OkhttpRestResult result = this.client.get(this.path(), name); + RestResult result = this.client.get(this.path(), name); return result.readObject(EdgeLabel.class); } public List list() { - OkhttpRestResult result = this.client.get(this.path()); + RestResult result = this.client.get(this.path()); return result.readList(this.type(), EdgeLabel.class); } @@ -78,12 +78,12 @@ public List list(List names) { E.checkArgument(names != null && !names.isEmpty(), "The edge label names can't be null or empty"); Map params = ImmutableMap.of("names", names); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(this.type(), EdgeLabel.class); } public long delete(String name) { - OkhttpRestResult result = this.client.delete(this.path(), name); + RestResult result = this.client.delete(this.path(), name); @SuppressWarnings("unchecked") Map task = result.readObject(Map.class); return TaskAPI.parseTaskId(task); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/IndexLabelAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/IndexLabelAPI.java index 3975eb563..aa8d08b79 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/IndexLabelAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/IndexLabelAPI.java @@ -23,7 +23,7 @@ import org.apache.hugegraph.api.task.TaskAPI; import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.NotSupportException; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.SchemaElement; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.constant.IndexType; @@ -45,7 +45,7 @@ protected String type() { public IndexLabel.IndexLabelWithTask create(IndexLabel indexLabel) { Object il = this.checkCreateOrUpdate(indexLabel); - OkhttpRestResult result = this.client.post(this.path(), il); + RestResult result = this.client.post(this.path(), il); return result.readObject(IndexLabel.IndexLabelWithTask.class); } @@ -57,7 +57,7 @@ public IndexLabel append(IndexLabel indexLabel) { String id = indexLabel.name(); Map params = ImmutableMap.of("action", "append"); Object il = this.checkCreateOrUpdate(indexLabel); - OkhttpRestResult result = this.client.put(this.path(), id, il, params); + RestResult result = this.client.put(this.path(), id, il, params); return result.readObject(IndexLabel.class); } @@ -69,17 +69,17 @@ public IndexLabel eliminate(IndexLabel indexLabel) { String id = indexLabel.name(); Map params = ImmutableMap.of("action", "eliminate"); Object il = this.checkCreateOrUpdate(indexLabel); - OkhttpRestResult result = this.client.put(this.path(), id, il, params); + RestResult result = this.client.put(this.path(), id, il, params); return result.readObject(IndexLabel.class); } public IndexLabel get(String name) { - OkhttpRestResult result = this.client.get(this.path(), name); + RestResult result = this.client.get(this.path(), name); return result.readObject(IndexLabel.class); } public List list() { - OkhttpRestResult result = this.client.get(this.path()); + RestResult result = this.client.get(this.path()); return result.readList(this.type(), IndexLabel.class); } @@ -88,12 +88,12 @@ public List list(List names) { E.checkArgument(names != null && !names.isEmpty(), "The index label names can't be null or empty"); Map params = ImmutableMap.of("names", names); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(this.type(), IndexLabel.class); } public long delete(String name) { - OkhttpRestResult result = this.client.delete(this.path(), name); + RestResult result = this.client.delete(this.path(), name); @SuppressWarnings("unchecked") Map task = result.readObject(Map.class); return TaskAPI.parseTaskId(task); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/PropertyKeyAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/PropertyKeyAPI.java index 783a2a3fd..11b3546bd 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/PropertyKeyAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/PropertyKeyAPI.java @@ -23,7 +23,7 @@ import org.apache.hugegraph.api.task.TaskAPI; import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.NotSupportException; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.SchemaElement; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.constant.WriteType; @@ -45,7 +45,7 @@ protected String type() { public PropertyKey.PropertyKeyWithTask create(PropertyKey propertyKey) { Object pkey = this.checkCreateOrUpdate(propertyKey); - OkhttpRestResult result = this.client.post(this.path(), pkey); + RestResult result = this.client.post(this.path(), pkey); if (this.client.apiVersionLt("0.65")) { return new PropertyKey.PropertyKeyWithTask(result.readObject(PropertyKey.class), 0L); } @@ -56,7 +56,7 @@ public PropertyKey.PropertyKeyWithTask append(PropertyKey propertyKey) { String id = propertyKey.name(); Map params = ImmutableMap.of("action", "append"); Object pkey = this.checkCreateOrUpdate(propertyKey); - OkhttpRestResult result = this.client.put(this.path(), id, pkey, params); + RestResult result = this.client.put(this.path(), id, pkey, params); return result.readObject(PropertyKey.PropertyKeyWithTask.class); } @@ -64,7 +64,7 @@ public PropertyKey.PropertyKeyWithTask eliminate(PropertyKey propertyKey) { String id = propertyKey.name(); Map params = ImmutableMap.of("action", "eliminate"); Object pkey = this.checkCreateOrUpdate(propertyKey); - OkhttpRestResult result = this.client.put(this.path(), id, pkey, params); + RestResult result = this.client.put(this.path(), id, pkey, params); return result.readObject(PropertyKey.PropertyKeyWithTask.class); } @@ -75,17 +75,17 @@ public PropertyKey.PropertyKeyWithTask clear(PropertyKey propertyKey) { String id = propertyKey.name(); Map params = ImmutableMap.of("action", "clear"); Object pkey = this.checkCreateOrUpdate(propertyKey); - OkhttpRestResult result = this.client.put(this.path(), id, pkey, params); + RestResult result = this.client.put(this.path(), id, pkey, params); return result.readObject(PropertyKey.PropertyKeyWithTask.class); } public PropertyKey get(String name) { - OkhttpRestResult result = this.client.get(this.path(), name); + RestResult result = this.client.get(this.path(), name); return result.readObject(PropertyKey.class); } public List list() { - OkhttpRestResult result = this.client.get(this.path()); + RestResult result = this.client.get(this.path()); return result.readList(this.type(), PropertyKey.class); } @@ -94,7 +94,7 @@ public List list(List names) { E.checkArgument(names != null && !names.isEmpty(), "The property key names can't be null or empty"); Map params = ImmutableMap.of("names", names); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(this.type(), PropertyKey.class); } @@ -103,7 +103,7 @@ public long delete(String name) { this.client.delete(this.path(), name); return 0L; } - OkhttpRestResult result = this.client.delete(this.path(), name); + RestResult result = this.client.delete(this.path(), name); @SuppressWarnings("unchecked") Map task = result.readObject(Map.class); return TaskAPI.parseTaskId(task); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaAPI.java index 2c0159d79..5b114aa3b 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/SchemaAPI.java @@ -23,7 +23,7 @@ import org.apache.hugegraph.api.API; import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.NotSupportException; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.SchemaElement; public class SchemaAPI extends API { @@ -40,7 +40,7 @@ public Map> list() { if (this.client.apiVersionLt("0.66")) { throw new NotSupportException("schema get api"); } - OkhttpRestResult result = this.client.get(this.path()); + RestResult result = this.client.get(this.path()); return result.readObject(Map.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/VertexLabelAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/VertexLabelAPI.java index 32d5d3204..79d2477ca 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/VertexLabelAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/schema/VertexLabelAPI.java @@ -22,7 +22,7 @@ import org.apache.hugegraph.api.task.TaskAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.SchemaElement; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.schema.VertexLabel; @@ -43,7 +43,7 @@ protected String type() { public VertexLabel create(VertexLabel vertexLabel) { Object vl = this.checkCreateOrUpdate(vertexLabel); - OkhttpRestResult result = this.client.post(this.path(), vl); + RestResult result = this.client.post(this.path(), vl); return result.readObject(VertexLabel.class); } @@ -51,7 +51,7 @@ public VertexLabel append(VertexLabel vertexLabel) { String id = vertexLabel.name(); Map params = ImmutableMap.of("action", "append"); Object vl = this.checkCreateOrUpdate(vertexLabel); - OkhttpRestResult result = this.client.put(this.path(), id, vl, params); + RestResult result = this.client.put(this.path(), id, vl, params); return result.readObject(VertexLabel.class); } @@ -59,17 +59,17 @@ public VertexLabel eliminate(VertexLabel vertexLabel) { String id = vertexLabel.name(); Map params = ImmutableMap.of("action", "eliminate"); Object vl = this.checkCreateOrUpdate(vertexLabel); - OkhttpRestResult result = this.client.put(this.path(), id, vl, params); + RestResult result = this.client.put(this.path(), id, vl, params); return result.readObject(VertexLabel.class); } public VertexLabel get(String name) { - OkhttpRestResult result = this.client.get(this.path(), name); + RestResult result = this.client.get(this.path(), name); return result.readObject(VertexLabel.class); } public List list() { - OkhttpRestResult result = this.client.get(this.path()); + RestResult result = this.client.get(this.path()); return result.readList(this.type(), VertexLabel.class); } @@ -78,12 +78,12 @@ public List list(List names) { E.checkArgument(names != null && !names.isEmpty(), "The vertex label names can't be null or empty"); Map params = ImmutableMap.of("names", names); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(this.type(), VertexLabel.class); } public long delete(String name) { - OkhttpRestResult result = this.client.delete(this.path(), name); + RestResult result = this.client.delete(this.path(), name); @SuppressWarnings("unchecked") Map task = result.readObject(Map.class); return TaskAPI.parseTaskId(task); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/task/TaskAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/task/TaskAPI.java index 6e4977e26..b348ef017 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/task/TaskAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/task/TaskAPI.java @@ -25,7 +25,7 @@ import org.apache.hugegraph.api.API; import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.rest.ClientException; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.Task; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.util.E; @@ -62,7 +62,7 @@ public List list(String status, long limit) { if (status != null) { params.put("status", status); } - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(TASKS, Task.class); } @@ -75,19 +75,19 @@ public TasksWithPage list(String status, String page, long limit) { if (status != null) { params.put("status", status); } - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readObject(TasksWithPage.class); } public List list(List ids) { Map params = new LinkedHashMap<>(); params.put("ids", ids); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(TASKS, Task.class); } public Task get(long id) { - OkhttpRestResult result = this.client.get(this.path(), String.valueOf(id)); + RestResult result = this.client.get(this.path(), String.valueOf(id)); return result.readObject(Task.class); } @@ -97,7 +97,7 @@ public void delete(long id) { public Task cancel(long id) { Map params = ImmutableMap.of("action", "cancel"); - OkhttpRestResult result = this.client.put(path(), String.valueOf(id), + RestResult result = this.client.put(path(), String.valueOf(id), ImmutableMap.of(), params); return result.readObject(Task.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/AllShortestPathsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/AllShortestPathsAPI.java index 580a53ed5..d692935f7 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/AllShortestPathsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/AllShortestPathsAPI.java @@ -23,7 +23,7 @@ import org.apache.hugegraph.api.graph.GraphAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; @@ -59,7 +59,7 @@ public List get(Object sourceId, Object targetId, params.put("max_degree", degree); params.put("skip_degree", skipDegree); params.put("capacity", capacity); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList("paths", Path.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CountAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CountAPI.java index fec6b7053..788e38797 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CountAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CountAPI.java @@ -20,7 +20,7 @@ import java.util.Map; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.traverser.CountRequest; import org.apache.hugegraph.util.E; @@ -39,7 +39,7 @@ protected String type() { public long post(CountRequest request) { this.client.checkApiVersion("0.55", "count"); - OkhttpRestResult result = this.client.post(this.path(), request); + RestResult result = this.client.post(this.path(), request); @SuppressWarnings("unchecked") Map countMap = result.readObject(Map.class); E.checkState(countMap.containsKey(COUNT), diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CrosspointsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CrosspointsAPI.java index 91ee8050c..196691013 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CrosspointsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CrosspointsAPI.java @@ -23,7 +23,7 @@ import org.apache.hugegraph.api.graph.GraphAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; @@ -59,7 +59,7 @@ public List get(Object sourceId, Object targetId, params.put("max_degree", degree); params.put("capacity", capacity); params.put("limit", limit); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList("crosspoints", Path.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedCrosspointsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedCrosspointsAPI.java index 378888e45..70eb94819 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedCrosspointsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedCrosspointsAPI.java @@ -18,7 +18,7 @@ package org.apache.hugegraph.api.traverser; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.traverser.CrosspointsRequest; import org.apache.hugegraph.structure.traverser.CustomizedCrosspoints; @@ -34,7 +34,7 @@ protected String type() { } public CustomizedCrosspoints post(CrosspointsRequest request) { - OkhttpRestResult result = this.client.post(this.path(), request); + RestResult result = this.client.post(this.path(), request); return result.readObject(CustomizedCrosspoints.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedPathsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedPathsAPI.java index 112d4a7f8..43a826f67 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedPathsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/CustomizedPathsAPI.java @@ -18,7 +18,7 @@ package org.apache.hugegraph.api.traverser; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.traverser.PathsWithVertices; import org.apache.hugegraph.structure.traverser.CustomizedPathsRequest; @@ -34,7 +34,7 @@ protected String type() { } public PathsWithVertices post(CustomizedPathsRequest request) { - OkhttpRestResult result = this.client.post(this.path(), request); + RestResult result = this.client.post(this.path(), request); return result.readObject(PathsWithVertices.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/EdgesAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/EdgesAPI.java index 2dea2e80d..162b9dec9 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/EdgesAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/EdgesAPI.java @@ -22,7 +22,7 @@ import java.util.Map; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.graph.Edge; import org.apache.hugegraph.structure.graph.Edges; import org.apache.hugegraph.structure.graph.Shard; @@ -47,14 +47,14 @@ public List list(List ids) { Map params = new LinkedHashMap<>(); params.put("ids", ids); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Edge.class); } public List shards(long splitSize) { String path = String.join(PATH_SPLITOR, this.path(), "shards"); Map params = ImmutableMap.of("split_size", splitSize); - OkhttpRestResult result = this.client.get(path, params); + RestResult result = this.client.get(path, params); return result.readList("shards", Shard.class); } @@ -66,7 +66,7 @@ public Edges scan(Shard shard, String page, long pageLimit) { params.put("end", shard.end()); params.put("page", page); params.put("page_limit", pageLimit); - OkhttpRestResult result = this.client.get(path, params); + RestResult result = this.client.get(path, params); return result.readObject(Edges.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/FusiformSimilarityAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/FusiformSimilarityAPI.java index 266590935..5987f0c60 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/FusiformSimilarityAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/FusiformSimilarityAPI.java @@ -18,7 +18,7 @@ package org.apache.hugegraph.api.traverser; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.traverser.FusiformSimilarity; import org.apache.hugegraph.structure.traverser.FusiformSimilarityRequest; @@ -35,7 +35,7 @@ protected String type() { public FusiformSimilarity post(FusiformSimilarityRequest request) { this.client.checkApiVersion("0.49", "fusiform similarity"); - OkhttpRestResult result = this.client.post(this.path(), request); + RestResult result = this.client.post(this.path(), request); return result.readObject(FusiformSimilarity.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java index 19cad68dd..80fe8b486 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java @@ -23,7 +23,7 @@ import org.apache.hugegraph.api.graph.GraphAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.traverser.SingleSourceJaccardSimilarityRequest; @@ -55,7 +55,7 @@ public double get(Object vertexId, Object otherId, Direction direction, params.put("direction", direction); params.put("label", label); params.put("max_degree", degree); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); @SuppressWarnings("unchecked") Map jaccard = result.readObject(Map.class); E.checkState(jaccard.containsKey(JACCARD_SIMILARITY), @@ -66,7 +66,7 @@ public double get(Object vertexId, Object otherId, Direction direction, @SuppressWarnings("unchecked") public Map post(SingleSourceJaccardSimilarityRequest request) { this.client.checkApiVersion("0.58", "jaccard similar"); - OkhttpRestResult result = this.client.post(this.path(), request); + RestResult result = this.client.post(this.path(), request); return result.readObject(Map.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KneighborAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KneighborAPI.java index 7105b3a7b..7470e28c2 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KneighborAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KneighborAPI.java @@ -23,7 +23,7 @@ import org.apache.hugegraph.api.graph.GraphAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.traverser.Kneighbor; import org.apache.hugegraph.structure.traverser.KneighborRequest; @@ -54,13 +54,13 @@ public List get(Object sourceId, Direction direction, params.put("max_depth", depth); params.put("max_degree", degree); params.put("limit", limit); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList("vertices", Object.class); } public Kneighbor post(KneighborRequest request) { this.client.checkApiVersion("0.58", "customized kneighbor"); - OkhttpRestResult result = this.client.post(this.path(), request); + RestResult result = this.client.post(this.path(), request); return result.readObject(Kneighbor.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KoutAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KoutAPI.java index 91ea1acef..ec9332715 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KoutAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/KoutAPI.java @@ -23,7 +23,7 @@ import org.apache.hugegraph.api.graph.GraphAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.traverser.Kout; import org.apache.hugegraph.structure.traverser.KoutRequest; @@ -58,13 +58,13 @@ public List get(Object sourceId, Direction direction, params.put("max_degree", degree); params.put("capacity", capacity); params.put("limit", limit); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList("vertices", Object.class); } public Kout post(KoutRequest request) { this.client.checkApiVersion("0.58", "customized kout"); - OkhttpRestResult result = this.client.post(this.path(), request); + RestResult result = this.client.post(this.path(), request); return result.readObject(Kout.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/MultiNodeShortestPathAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/MultiNodeShortestPathAPI.java index 637133536..8036d41c8 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/MultiNodeShortestPathAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/MultiNodeShortestPathAPI.java @@ -18,7 +18,7 @@ package org.apache.hugegraph.api.traverser; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.traverser.MultiNodeShortestPathRequest; import org.apache.hugegraph.structure.traverser.PathsWithVertices; @@ -35,7 +35,7 @@ protected String type() { public PathsWithVertices post(MultiNodeShortestPathRequest request) { this.client.checkApiVersion("0.58", "multi node shortest path"); - OkhttpRestResult result = this.client.post(this.path(), request); + RestResult result = this.client.post(this.path(), request); return result.readObject(PathsWithVertices.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/NeighborRankAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/NeighborRankAPI.java index 12cf074ed..d70573379 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/NeighborRankAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/NeighborRankAPI.java @@ -22,7 +22,7 @@ import java.util.List; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.constant.Traverser; import org.apache.hugegraph.structure.traverser.Ranks; @@ -42,7 +42,7 @@ protected String type() { } public List post(Request request) { - OkhttpRestResult result = this.client.post(this.path(), request); + RestResult result = this.client.post(this.path(), request); return result.readList("ranks", Ranks.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PathsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PathsAPI.java index 9f2cd8d42..2d14cae79 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PathsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PathsAPI.java @@ -23,7 +23,7 @@ import org.apache.hugegraph.api.graph.GraphAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; import org.apache.hugegraph.structure.traverser.PathsRequest; @@ -61,13 +61,13 @@ public List get(Object sourceId, Object targetId, params.put("max_degree", degree); params.put("capacity", capacity); params.put("limit", limit); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList("paths", Path.class); } public PathsWithVertices post(PathsRequest request) { this.client.checkApiVersion("0.58", "paths with property filter"); - OkhttpRestResult result = this.client.post(this.path(), request); + RestResult result = this.client.post(this.path(), request); return result.readObject(PathsWithVertices.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PersonalRankAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PersonalRankAPI.java index 8641bef04..5d7fbb2b1 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PersonalRankAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/PersonalRankAPI.java @@ -18,7 +18,7 @@ package org.apache.hugegraph.api.traverser; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.Traverser; import org.apache.hugegraph.structure.traverser.Ranks; import org.apache.hugegraph.util.E; @@ -37,7 +37,7 @@ protected String type() { } public Ranks post(Request request) { - OkhttpRestResult result = this.client.post(this.path(), request); + RestResult result = this.client.post(this.path(), request); return result.readObject(Ranks.class); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RaysAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RaysAPI.java index e164cac35..9908b311b 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RaysAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RaysAPI.java @@ -23,7 +23,7 @@ import org.apache.hugegraph.api.graph.GraphAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; @@ -55,7 +55,7 @@ public List get(Object sourceId, Direction direction, String label, params.put("max_degree", degree); params.put("capacity", capacity); params.put("limit", limit); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Path.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RingsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RingsAPI.java index 067b4d4ad..26aaff444 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RingsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/RingsAPI.java @@ -23,7 +23,7 @@ import org.apache.hugegraph.api.graph.GraphAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; @@ -62,7 +62,7 @@ public List get(Object sourceId, Direction direction, String label, params.put("max_degree", degree); params.put("capacity", capacity); params.put("limit", limit); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Path.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SameNeighborsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SameNeighborsAPI.java index 7a8687f7a..1ef4b9ce5 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SameNeighborsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SameNeighborsAPI.java @@ -23,7 +23,7 @@ import org.apache.hugegraph.api.graph.GraphAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.Direction; public class SameNeighborsAPI extends TraversersAPI { @@ -53,7 +53,7 @@ public List get(Object vertexId, Object otherId, params.put("label", label); params.put("max_degree", degree); params.put("limit", limit); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(SAME_NEIGHBORS, Object.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/ShortestPathAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/ShortestPathAPI.java index e92d6f72c..4b5cfa99a 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/ShortestPathAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/ShortestPathAPI.java @@ -23,7 +23,7 @@ import org.apache.hugegraph.api.graph.GraphAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.graph.Path; @@ -58,7 +58,7 @@ public Path get(Object sourceId, Object targetId, params.put("max_degree", degree); params.put("skip_degree", skipDegree); params.put("capacity", capacity); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); List vertices = result.readList("path", Object.class); return new Path(vertices); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SingleSourceShortestPathAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SingleSourceShortestPathAPI.java index c095ab145..a1930fc31 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SingleSourceShortestPathAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/SingleSourceShortestPathAPI.java @@ -22,7 +22,7 @@ import org.apache.hugegraph.api.graph.GraphAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.traverser.WeightedPaths; import org.apache.hugegraph.util.E; @@ -60,7 +60,7 @@ public WeightedPaths get(Object sourceId, Direction direction, String label, params.put("capacity", capacity); params.put("limit", limit); params.put("with_vertex", withVertex); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readObject(WeightedPaths.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TemplatePathsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TemplatePathsAPI.java index bcc99316d..2f198738b 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TemplatePathsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/TemplatePathsAPI.java @@ -18,7 +18,7 @@ package org.apache.hugegraph.api.traverser; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.traverser.PathsWithVertices; import org.apache.hugegraph.structure.traverser.TemplatePathsRequest; @@ -35,7 +35,7 @@ protected String type() { public PathsWithVertices post(TemplatePathsRequest request) { this.client.checkApiVersion("0.58", "template paths"); - OkhttpRestResult result = this.client.post(this.path(), request); + RestResult result = this.client.post(this.path(), request); return result.readObject(PathsWithVertices.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/VerticesAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/VerticesAPI.java index 3456de36c..c80a4fa77 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/VerticesAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/VerticesAPI.java @@ -24,7 +24,7 @@ import org.apache.hugegraph.api.graph.GraphAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.graph.Shard; import org.apache.hugegraph.structure.graph.Vertex; import org.apache.hugegraph.structure.graph.Vertices; @@ -54,14 +54,14 @@ public List list(List ids) { Map params = new LinkedHashMap<>(); params.put("ids", stringIds); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readList(this.type(), Vertex.class); } public List shards(long splitSize) { String path = String.join(PATH_SPLITOR, this.path(), "shards"); Map params = ImmutableMap.of("split_size", splitSize); - OkhttpRestResult result = this.client.get(path, params); + RestResult result = this.client.get(path, params); return result.readList("shards", Shard.class); } @@ -73,7 +73,7 @@ public Vertices scan(Shard shard, String page, long pageLimit) { params.put("end", shard.end()); params.put("page", page); params.put("page_limit", pageLimit); - OkhttpRestResult result = this.client.get(path, params); + RestResult result = this.client.get(path, params); return result.readObject(Vertices.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/WeightedShortestPathAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/WeightedShortestPathAPI.java index e400f18fb..7cf2a3b25 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/WeightedShortestPathAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/WeightedShortestPathAPI.java @@ -22,7 +22,7 @@ import org.apache.hugegraph.api.graph.GraphAPI; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.traverser.WeightedPath; import org.apache.hugegraph.util.E; @@ -61,7 +61,7 @@ public WeightedPath get(Object sourceId, Object targetId, params.put("skip_degree", skipDegree); params.put("capacity", capacity); params.put("with_vertex", withVertex); - OkhttpRestResult result = this.client.get(this.path(), params); + RestResult result = this.client.get(this.path(), params); return result.readObject(WeightedPath.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/variables/VariablesAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/variables/VariablesAPI.java index 541a9dcc4..016be729b 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/variables/VariablesAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/variables/VariablesAPI.java @@ -21,7 +21,7 @@ import org.apache.hugegraph.api.API; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.HugeType; import com.google.common.collect.ImmutableMap; @@ -42,14 +42,14 @@ protected String type() { @SuppressWarnings("unchecked") public Map get(String key) { - OkhttpRestResult result = this.client.get(path(), key); + RestResult result = this.client.get(path(), key); return result.readObject(Map.class); } @SuppressWarnings("unchecked") public Map set(String key, Object value) { value = ImmutableMap.of("data", value); - OkhttpRestResult result = this.client.put(this.path(), key, value); + RestResult result = this.client.put(this.path(), key, value); return result.readObject(Map.class); } @@ -59,7 +59,7 @@ public void remove(String key) { @SuppressWarnings("unchecked") public Map all() { - OkhttpRestResult result = this.client.get(path()); + RestResult result = this.client.get(path()); return result.readObject(Map.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/version/VersionAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/version/VersionAPI.java index 9a3c42f2c..2071a3411 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/version/VersionAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/version/VersionAPI.java @@ -19,7 +19,7 @@ import org.apache.hugegraph.api.API; import org.apache.hugegraph.client.RestClient; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.structure.constant.HugeType; import org.apache.hugegraph.structure.version.Versions; @@ -36,7 +36,7 @@ protected String type() { } public Versions get() { - OkhttpRestResult result = this.client.get(this.path()); + RestResult result = this.client.get(this.path()); return result.readObject(Versions.class); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java index 7421d83a6..d54a1f5d9 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java @@ -21,16 +21,16 @@ import org.apache.hugegraph.exception.ServerException; import org.apache.hugegraph.serializer.PathDeserializer; import org.apache.hugegraph.structure.graph.Path; -import org.apache.hugegraph.rest.OkhttpAbstractRestClient; +import org.apache.hugegraph.rest.AbstractRestClient; import org.apache.hugegraph.rest.ClientException; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.util.E; import org.apache.hugegraph.util.VersionUtil; import org.apache.hugegraph.util.VersionUtil.Version; import com.fasterxml.jackson.databind.module.SimpleModule; -public class RestClient extends OkhttpAbstractRestClient { +public class RestClient extends AbstractRestClient { private static final int SECOND = 1000; @@ -39,7 +39,7 @@ public class RestClient extends OkhttpAbstractRestClient { static { SimpleModule module = new SimpleModule(); module.addDeserializer(Path.class, new PathDeserializer()); - OkhttpRestResult.registerModule(module); + RestResult.registerModule(module); } public RestClient(String url, String username, String password, diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java index 995d372b6..d28e451e0 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java @@ -19,7 +19,7 @@ import java.util.Map; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,7 +45,7 @@ public class ServerException extends RuntimeException { private Object trace; public static ServerException fromResponse(Response response) { - OkhttpRestResult rs = new OkhttpRestResult(response); + RestResult rs = new RestResult(response); ServerException exception = new ServerException(rs.content()); exception.status(response.code()); try { diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpAbstractRestClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpAbstractRestClient.java deleted file mode 100644 index 9c8532e9f..000000000 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpAbstractRestClient.java +++ /dev/null @@ -1,449 +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.hugegraph.rest; - -import com.google.common.collect.ImmutableMap; -import lombok.SneakyThrows; -import okhttp3.*; -import okio.BufferedSink; -import okio.GzipSink; -import okio.Okio; -import org.apache.commons.lang3.StringUtils; -import org.apache.hugegraph.util.JsonUtil; - -import javax.net.ssl.*; -import java.io.FileInputStream; -import java.io.IOException; -import java.net.URI; -import java.security.KeyStore; -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -public abstract class OkhttpAbstractRestClient implements OkhttpRestClient { - - private OkHttpClient client; - - private String baseUrl; - - public OkhttpAbstractRestClient(String url, int timeout) { - this(url, OkhttpConfig.builder() - .timeout(timeout) - .build()); - } - - public OkhttpAbstractRestClient(String url, String user, String password, - Integer timeout) { - this(url, OkhttpConfig.builder() - .user(user).password(password) - .timeout(timeout) - .build()); - } - - public OkhttpAbstractRestClient(String url, int timeout, - int maxTotal, int maxPerRoute) { - this(url, null, null, timeout, maxTotal, maxPerRoute); - } - - public OkhttpAbstractRestClient(String url, int timeout, int idleTime, - int maxTotal, int maxPerRoute) { - this(url, OkhttpConfig.builder() - .idleTime(idleTime) - .timeout(timeout) - .maxTotal(maxTotal) - .maxPerRoute(maxPerRoute) - .build()); - } - - public OkhttpAbstractRestClient(String url, String user, String password, - int timeout, int maxTotal, int maxPerRoute) { - this(url, OkhttpConfig.builder() - .user(user).password(password) - .timeout(timeout) - .maxTotal(maxTotal) - .maxPerRoute(maxPerRoute) - .build()); - } - - public OkhttpAbstractRestClient(String url, String user, String password, - int timeout, int maxTotal, int maxPerRoute, - String trustStoreFile, - String trustStorePassword) { - this(url, OkhttpConfig.builder() - .user(user).password(password) - .timeout(timeout) - .maxTotal(maxTotal) - .maxPerRoute(maxPerRoute) - .trustStoreFile(trustStoreFile) - .trustStorePassword(trustStorePassword) - .build()); - } - - public OkhttpAbstractRestClient(String url, String token, Integer timeout) { - this(url, OkhttpConfig.builder() - .token(token) - .timeout(timeout) - .build()); - } - - public OkhttpAbstractRestClient(String url, String token, Integer timeout, - Integer maxTotal, Integer maxPerRoute) { - this(url,OkhttpConfig.builder() - .token(token) - .timeout(timeout) - .maxTotal(maxTotal) - .maxPerRoute(maxPerRoute) - .build()); - } - - public OkhttpAbstractRestClient(String url, String token, Integer timeout, - Integer maxTotal, Integer maxPerRoute, - String trustStoreFile, - String trustStorePassword) { - this(url,OkhttpConfig.builder() - .token(token) - .timeout(timeout) - .maxTotal(maxTotal) - .maxPerRoute(maxPerRoute) - .trustStoreFile(trustStoreFile) - .trustStorePassword(trustStorePassword) - .build()); - } - - public OkhttpAbstractRestClient(String url, OkhttpConfig okhttpConfig) { - this.baseUrl = url; - this.client = getOkhttpClient(okhttpConfig); - } - - private OkHttpClient getOkhttpClient(OkhttpConfig okhttpConfig) { - OkHttpClient.Builder builder = new OkHttpClient.Builder(); - - if(okhttpConfig.getTimeout()!=null) { - builder.connectTimeout(okhttpConfig.getTimeout(), TimeUnit.MILLISECONDS) - .readTimeout(okhttpConfig.getTimeout(), TimeUnit.MILLISECONDS); - } - - if(okhttpConfig.getIdleTime()!=null) { - ConnectionPool connectionPool = new ConnectionPool(5, okhttpConfig.getIdleTime(), TimeUnit.MILLISECONDS); - builder.connectionPool(connectionPool); - } - - - //auth - if(StringUtils.isNotBlank(okhttpConfig.getUser()) && StringUtils.isNotBlank(okhttpConfig.getPassword())) { - builder.addInterceptor(new OkhttpBasicAuthInterceptor(okhttpConfig.getUser(), okhttpConfig.getPassword())); - } - if(StringUtils.isNotBlank(okhttpConfig.getToken())) { - builder.addInterceptor(new OkhttpTokenInterceptor(okhttpConfig.getToken())); - } - - //ssl - configSsl(builder, baseUrl, okhttpConfig.getTrustStoreFile(), okhttpConfig.getTrustStorePassword()); - - OkHttpClient okHttpClient = builder.build(); - - if(okhttpConfig.getMaxTotal()!=null) { - okHttpClient.dispatcher().setMaxRequests(okhttpConfig.getMaxTotal()); - } - - if(okhttpConfig.getMaxPerRoute()!=null) { - okHttpClient.dispatcher().setMaxRequestsPerHost(okhttpConfig.getMaxPerRoute()); - } - - return okHttpClient; - } - - @SneakyThrows - private void configSsl(OkHttpClient.Builder builder, String url, String trustStoreFile, String trustStorePass) { - if(StringUtils.isBlank(trustStoreFile) || StringUtils.isBlank(trustStorePass)) { - return; - } - - X509TrustManager trustManager = trustManagerForCertificates(trustStoreFile, trustStorePass); - SSLContext sslContext = SSLContext.getInstance("TLS"); - sslContext.init(null, new TrustManager[]{trustManager}, null); - SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); - - builder.sslSocketFactory(sslSocketFactory, trustManager) - .hostnameVerifier(new CustomHostnameVerifier(url)); - } - - @Override - public OkhttpRestResult post(String path, Object object) { - return this.post(path, object, null, null); - } - - @Override - public OkhttpRestResult post(String path, Object object, Headers headers) { - return this.post(path, object, headers, null); - } - - @Override - public OkhttpRestResult post(String path, Object object, Map params) { - return this.post(path, object, null, params); - } - - private Request.Builder getRequestBuilder(String path, String id, Headers headers, Map params ) { - HttpUrl.Builder urlBuilder = HttpUrl.parse(baseUrl).newBuilder() - .addPathSegments(path); - if(id!=null) { - urlBuilder.addPathSegment(id); - } - - if(params!=null) { - params.forEach((name, value) -> { - if(value==null){ - return; - } - - if(value instanceof Collection) { - for (Object i : (Collection) value) { - urlBuilder.addQueryParameter(name, String.valueOf(i)); - } - } else { - urlBuilder.addQueryParameter(name, String.valueOf(value)); - } - }); - } - - Request.Builder builder = new Request.Builder() - .url(urlBuilder.build()); - - if(headers!=null) { - builder.headers(headers); - } - - this.attachAuthToRequest(builder); - - return builder; - } - - private static RequestBody getRequestBody(Object object, Headers headers) { - String contentType = parseContentType(headers); - String bodyContent = "application/json".equals(contentType) ? JsonUtil.toJson(object) : String.valueOf(object); - - RequestBody requestBody = RequestBody.create(MediaType.parse(contentType), bodyContent); - if(headers!=null && "gzip".equals(headers.get("Content-Encoding"))) { - requestBody = gzip(requestBody); - } - return requestBody; - } - - private static RequestBody gzip(final RequestBody body) { - return new RequestBody() { - @Override public MediaType contentType() { - return body.contentType(); - } - - @Override public long contentLength() { - return -1; // We don't know the compressed length in advance! - } - - @Override public void writeTo(BufferedSink sink) throws IOException { - BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); - body.writeTo(gzipSink); - gzipSink.close(); - } - }; - } - - @SneakyThrows - @Override - public OkhttpRestResult post(String path, Object object, - Headers headers, - Map params) { - Request.Builder requestBuilder = getRequestBuilder(path, null, headers, params); - requestBuilder.post(getRequestBody(object, headers)); - - try (Response response = client.newCall(requestBuilder.build()).execute()) { - checkStatus(response, 200, 201, 202); - return new OkhttpRestResult(response); - } - } - - @Override - public OkhttpRestResult put(String path, String id, Object object) { - return this.put(path, id, object, ImmutableMap.of()); - } - - @Override - public OkhttpRestResult put(String path, String id, Object object, - Headers headers) { - return this.put(path, id, object, headers, null); - } - - @Override - public OkhttpRestResult put(String path, String id, Object object, - Map params) { - return this.put(path, id, object, null, params); - } - - @SneakyThrows - @Override - public OkhttpRestResult put(String path, String id, Object object, - Headers headers, - Map params) { - Request.Builder requestBuilder = getRequestBuilder(path, id, headers, params); - requestBuilder.put(getRequestBody(object, headers)); - - try (Response response = client.newCall(requestBuilder.build()).execute()) { - checkStatus(response, 200, 202); - return new OkhttpRestResult(response); - } - } - - private static String parseContentType(Headers headers) { - if(headers!=null) { - String contentType = headers.get("Content-Type"); - if(contentType!=null) { - return contentType; - } - } - return "application/json"; - } - - @Override - public OkhttpRestResult get(String path) { - return this.get(path, null, ImmutableMap.of()); - } - - @Override - public OkhttpRestResult get(String path, Map params) { - return this.get(path, null, params); - } - - @Override - public OkhttpRestResult get(String path, String id) { - return this.get(path, id, ImmutableMap.of()); - } - - @SneakyThrows - private OkhttpRestResult get(String path, String id, Map params) { - Request.Builder requestBuilder = getRequestBuilder(path, id, null, params); - - try (Response response = client.newCall(requestBuilder.build()).execute()) { - checkStatus(response, 200); - return new OkhttpRestResult(response); - } - } - - - @Override - public OkhttpRestResult delete(String path, Map params) { - return this.delete(path, null, params); - } - - @Override - public OkhttpRestResult delete(String path, String id) { - return this.delete(path, id, ImmutableMap.of()); - } - - @SneakyThrows - private OkhttpRestResult delete(String path, String id, - Map params) { - Request.Builder requestBuilder = getRequestBuilder(path, id, null, params); - requestBuilder.delete(); - - try (Response response = client.newCall(requestBuilder.build()).execute()) { - checkStatus(response, 204, 202); - return new OkhttpRestResult(response); - } - } - - protected abstract void checkStatus(Response response, int... statuses); - - @SneakyThrows - @Override - public void close() { - if(client!=null) { - client.dispatcher().executorService().shutdown(); - client.connectionPool().evictAll(); - if(client.cache()!=null) { - client.cache().close(); - } - } - } - - private final ThreadLocal authContext = - new InheritableThreadLocal<>(); - - public void setAuthContext(String auth) { - this.authContext.set(auth); - } - - public void resetAuthContext() { - this.authContext.remove(); - } - - public String getAuthContext() { - return this.authContext.get(); - } - - private void attachAuthToRequest(Request.Builder builder) { - // Add auth header - String auth = this.getAuthContext(); - if (StringUtils.isNotEmpty(auth)) { - builder.addHeader("Authorization", auth); - } - } - - @SneakyThrows - private X509TrustManager trustManagerForCertificates(String trustStoreFile, String trustStorePass){ - char[] password = trustStorePass.toCharArray(); - - //load keyStore - KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); - try(FileInputStream in = new FileInputStream(trustStoreFile)) { - keyStore.load(in, password); - } - - TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); - trustManagerFactory.init(keyStore); - - TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); - if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) { - throw new IllegalStateException("Unexpected default trust managers:" - + Arrays.toString(trustManagers)); - } - return (X509TrustManager) trustManagers[0]; - } - - private class CustomHostnameVerifier implements HostnameVerifier { - private final String url; - - public CustomHostnameVerifier(String url) { - if (!url.startsWith("http://") && !url.startsWith("https://")) { - url = "http://" + url; - } - url = URI.create(url).getHost(); - this.url = url; - } - - @Override - public boolean verify(String hostname, SSLSession session) { - if (!this.url.isEmpty() && this.url.endsWith(hostname)) { - return true; - } else { - HostnameVerifier verifier = HttpsURLConnection.getDefaultHostnameVerifier(); - return verifier.verify(hostname, session); - } - } - } - -} diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpBasicAuthInterceptor.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpBasicAuthInterceptor.java deleted file mode 100644 index 7a0e69691..000000000 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpBasicAuthInterceptor.java +++ /dev/null @@ -1,45 +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.hugegraph.rest; - -import okhttp3.Credentials; -import okhttp3.Interceptor; -import okhttp3.Request; -import okhttp3.Response; - -import java.io.IOException; - -public class OkhttpBasicAuthInterceptor implements Interceptor { - - private String credentials; - - public OkhttpBasicAuthInterceptor(String user, String password) { - this.credentials = Credentials.basic(user, password); - } - - @Override - public Response intercept(Chain chain) throws IOException { - Request request = chain.request(); - if(request.header("Authorization")==null) { - Request authenticatedRequest = request.newBuilder() - .header("Authorization", credentials).build(); - return chain.proceed(authenticatedRequest); - } - return chain.proceed(request); - } -} diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpConfig.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpConfig.java deleted file mode 100644 index 5d5c62da9..000000000 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpConfig.java +++ /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. - */ - -package org.apache.hugegraph.rest; - -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; - -@Builder -@Getter -@Setter -public class OkhttpConfig { - private String user; - private String password; - private String token; - private Integer timeout; - private Integer maxTotal; - private Integer maxPerRoute; - private Integer idleTime; - private String trustStoreFile; - private String trustStorePassword; -} diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpRestClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpRestClient.java deleted file mode 100644 index dcaf1886c..000000000 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpRestClient.java +++ /dev/null @@ -1,64 +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.hugegraph.rest; - -import okhttp3.Headers; - -import java.util.Map; - -public interface OkhttpRestClient { - /** - * Post method - */ - OkhttpRestResult post(String path, Object object); - - OkhttpRestResult post(String path, Object object, Headers headers); - OkhttpRestResult post(String path, Object object, Map params); - - OkhttpRestResult post(String path, Object object, Headers headers, - Map params); - - /** - * Put method - */ - OkhttpRestResult put(String path, String id, Object object); - OkhttpRestResult put(String path, String id, Object object, Headers headers); - - OkhttpRestResult put(String path, String id, Object object, Map params); - - OkhttpRestResult put(String path, String id, Object object, Headers headers, - Map params); - - /** - * Get method - */ - OkhttpRestResult get(String path); - - OkhttpRestResult get(String path, Map params); - - OkhttpRestResult get(String path, String id); - - /** - * Delete method - */ - OkhttpRestResult delete(String path, Map params); - - OkhttpRestResult delete(String path, String id); - - void close(); -} diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpRestResult.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpRestResult.java deleted file mode 100644 index f2ffc6d60..000000000 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpRestResult.java +++ /dev/null @@ -1,118 +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.hugegraph.rest; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.Module; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.SneakyThrows; -import okhttp3.Headers; -import okhttp3.Response; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -public class OkhttpRestResult { - - private static final ObjectMapper MAPPER = new ObjectMapper(); - - private final int status; - private final Headers headers; - private final String content; - - public OkhttpRestResult(Response response) { - this(response.code(), getResponseContent(response), response.headers()); - } - - @SneakyThrows - private static String getResponseContent(Response response) { - return response.body().string(); - } - - public OkhttpRestResult(int status, String content, - Headers headers) { - this.status = status; - this.headers = headers; - this.content = content; - } - - public int status() { - return this.status; - } - - public Headers headers() { - return this.headers; - } - - public String content() { - return this.content; - } - - public T readObject(Class clazz) { - try { - return MAPPER.readValue(this.content, clazz); - } catch (Exception e) { - throw new SerializeException( - "Failed to deserialize: %s", e, this.content); - } - } - - @SuppressWarnings("deprecation") - public List readList(String key, Class clazz) { - try { - JsonNode root = MAPPER.readTree(this.content); - JsonNode element = root.get(key); - if (element == null) { - throw new SerializeException( - "Can't find value of the key: %s in json.", key); - } - JavaType type = MAPPER.getTypeFactory() - .constructParametrizedType(ArrayList.class, - List.class, clazz); - return MAPPER.convertValue(element, type); - } catch (IOException e) { - throw new SerializeException( - "Failed to deserialize %s", e, this.content); - } - } - - @SuppressWarnings("deprecation") - public List readList(Class clazz) { - JavaType type = MAPPER.getTypeFactory() - .constructParametrizedType(ArrayList.class, - List.class, clazz); - try { - return MAPPER.readValue(this.content, type); - } catch (IOException e) { - throw new SerializeException( - "Failed to deserialize %s", e, this.content); - } - } - - @Override - public String toString() { - return String.format("{status=%s, headers=%s, content=%s}", - this.status, this.headers, this.content); - } - - public static void registerModule(Module module) { - MAPPER.registerModule(module); - } -} diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpTokenInterceptor.java b/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpTokenInterceptor.java deleted file mode 100644 index 8a3be2835..000000000 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/rest/OkhttpTokenInterceptor.java +++ /dev/null @@ -1,44 +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.hugegraph.rest; - -import okhttp3.Interceptor; -import okhttp3.Request; -import okhttp3.Response; - -import java.io.IOException; - -public class OkhttpTokenInterceptor implements Interceptor { - - private String token; - - public OkhttpTokenInterceptor(String token) { - this.token = token; - } - - @Override - public Response intercept(Chain chain) throws IOException { - Request request = chain.request(); - if(request.header("Authorization")==null) { - Request authenticatedRequest = request.newBuilder() - .header("Authorization", "Bearer "+token).build(); - return chain.proceed(authenticatedRequest); - } - return chain.proceed(request); - } -} diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java index c19233535..d13b7224e 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java @@ -24,7 +24,8 @@ import lombok.SneakyThrows; import org.apache.hugegraph.driver.GraphManager; -import org.apache.hugegraph.rest.OkhttpRestResult; +import org.apache.hugegraph.rest.RestHeaders; +import org.apache.hugegraph.rest.RestResult; import org.apache.hugegraph.serializer.PathDeserializer; import org.apache.hugegraph.structure.constant.Cardinality; import org.apache.hugegraph.structure.constant.DataType; @@ -65,7 +66,7 @@ public static void init() { SimpleModule module = new SimpleModule(); module.addDeserializer(Path.class, new PathDeserializer()); - OkhttpRestResult.registerModule(module); + RestResult.registerModule(module); } public static GraphManager graph() { @@ -96,11 +97,10 @@ public void testReadPropertyKey() { Mockito.when(this.mockResponse.code()).thenReturn(200); Mockito.when(this.mockResponse.headers()).thenReturn(null); - Mockito.when(this.mockResponse.body().string()) - .thenReturn(json); - OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); + Mockito.when(this.mockResponse.body().string()).thenReturn(json); + RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); - Assert.assertNull(result.headers()); + Assert.assertEquals(result.headers(), new RestHeaders()); PropertyKey propertyKey = result.readObject(PropertyKey.class); @@ -133,9 +133,9 @@ public void testReadPropertyKeys() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); + RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); - Assert.assertNull(result.headers()); + Assert.assertEquals(result.headers(), new RestHeaders()); List propertyKeys = result.readList("propertykeys", PropertyKey.class); @@ -170,9 +170,9 @@ public void testReadVertexLabel() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); + RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); - Assert.assertNull(result.headers()); + Assert.assertEquals(result.headers(), new RestHeaders()); VertexLabel vertexLabel = result.readObject(VertexLabel.class); @@ -210,9 +210,9 @@ public void testReadVertexLabels() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); + RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); - Assert.assertNull(result.headers()); + Assert.assertEquals(result.headers(), new RestHeaders()); List vertexLabels = result.readList("vertexlabels", VertexLabel.class); @@ -253,9 +253,9 @@ public void testReadEdgeLabel() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); + RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); - Assert.assertNull(result.headers()); + Assert.assertEquals(result.headers(), new RestHeaders()); EdgeLabel edgeLabel = result.readObject(EdgeLabel.class); @@ -296,9 +296,9 @@ public void testReadEdgeLabels() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); + RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); - Assert.assertNull(result.headers()); + Assert.assertEquals(result.headers(), new RestHeaders()); List edgeLabels = result.readList("edgelabels", EdgeLabel.class); @@ -338,9 +338,9 @@ public void testReadIndexLabel() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); + RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); - Assert.assertNull(result.headers()); + Assert.assertEquals(result.headers(), new RestHeaders()); IndexLabel indexLabel = result.readObject(IndexLabel.class); @@ -378,9 +378,9 @@ public void testReadIndexLabels() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); + RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); - Assert.assertNull(result.headers()); + Assert.assertEquals(result.headers(), new RestHeaders()); List indexLabels = result.readList("indexlabels", IndexLabel.class); @@ -419,9 +419,9 @@ public void testReadVertex() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); + RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); - Assert.assertNull(result.headers()); + Assert.assertEquals(result.headers(), new RestHeaders()); Vertex vertex = result.readObject(Vertex.class); @@ -471,9 +471,9 @@ public void testReadVertices() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); + RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); - Assert.assertNull(result.headers()); + Assert.assertEquals(result.headers(), new RestHeaders()); List vertices = result.readList("vertices", Vertex.class); Assert.assertEquals(3, vertices.size()); @@ -529,9 +529,9 @@ public void testReadEdge() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); + RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); - Assert.assertNull(result.headers()); + Assert.assertEquals(result.headers(), new RestHeaders()); Edge edge = result.readObject(Edge.class); @@ -581,9 +581,9 @@ public void testReadEdges() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult result = new OkhttpRestResult(this.mockResponse); + RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); - Assert.assertNull(result.headers()); + Assert.assertEquals(result.headers(), new RestHeaders()); List edges = result.readList("edges", Edge.class); Assert.assertEquals(2, edges.size()); @@ -661,9 +661,9 @@ public void testReadGremlinVertices() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult restResult = new OkhttpRestResult(this.mockResponse); + RestResult restResult = new RestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); - Assert.assertNull(restResult.headers()); + Assert.assertEquals(restResult.headers(), new RestHeaders()); Response response = restResult.readObject(Response.class); response.graphManager(graph()); @@ -750,9 +750,9 @@ public void testReadGremlinEdges() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult restResult = new OkhttpRestResult(this.mockResponse); + RestResult restResult = new RestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); - Assert.assertNull(restResult.headers()); + Assert.assertEquals(restResult.headers(), new RestHeaders()); Response response = restResult.readObject(Response.class); response.graphManager(graph()); @@ -839,9 +839,9 @@ public void testReadGremlinPathWithVertexAndEdge() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult restResult = new OkhttpRestResult(this.mockResponse); + RestResult restResult = new RestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); - Assert.assertNull(restResult.headers()); + Assert.assertEquals(restResult.headers(), new RestHeaders()); Response response = restResult.readObject(Response.class); response.graphManager(graph()); @@ -898,9 +898,9 @@ public void testReadGremlinNullData() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult restResult = new OkhttpRestResult(this.mockResponse); + RestResult restResult = new RestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); - Assert.assertNull(restResult.headers()); + Assert.assertEquals(restResult.headers(), new RestHeaders()); Response response = restResult.readObject(Response.class); response.graphManager(graph()); @@ -944,9 +944,9 @@ public void testReadGremlinNullAndVertex() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult restResult = new OkhttpRestResult(this.mockResponse); + RestResult restResult = new RestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); - Assert.assertNull(restResult.headers()); + Assert.assertEquals(restResult.headers(), new RestHeaders()); Response response = restResult.readObject(Response.class); response.graphManager(graph()); @@ -1005,9 +1005,9 @@ public void testReadGremlinEdgeAndNull() { Mockito.when(this.mockResponse.headers()).thenReturn(null); Mockito.when(this.mockResponse.body().string()) .thenReturn(json); - OkhttpRestResult restResult = new OkhttpRestResult(this.mockResponse); + RestResult restResult = new RestResult(this.mockResponse); Assert.assertEquals(200, restResult.status()); - Assert.assertNull(restResult.headers()); + Assert.assertEquals(restResult.headers(), new RestHeaders()); Response response = restResult.readObject(Response.class); response.graphManager(graph()); diff --git a/hugegraph-spark-connector/pom.xml b/hugegraph-spark-connector/pom.xml index 5f595f079..3a717c752 100644 --- a/hugegraph-spark-connector/pom.xml +++ b/hugegraph-spark-connector/pom.xml @@ -38,8 +38,8 @@ provided 1.0.0 2.12.3 - 3.0.3 - 2.34 + + 2.18.0 1.7.25 2.12.11 @@ -95,33 +95,33 @@ - - org.glassfish.jersey.core - jersey-client - ${jersey.version} - - - org.glassfish.jersey.core - jersey-common - ${jersey.version} - - - org.glassfish.jersey.inject - jersey-hk2 - ${jersey.version} - - - org.glassfish.jersey.core - jersey-server - ${jersey.version} - + + + + + + + + + + + + + + + + + + + + - - org.glassfish.jersey.containers - jersey-container-servlet-core - ${jersey.container.servlet.core.version} - provided - + + + + + + diff --git a/pom.xml b/pom.xml index 882262739..73b5ee716 100644 --- a/pom.xml +++ b/pom.xml @@ -120,7 +120,7 @@ hugegraph ${project.name} ${project.version} - 1.0.0 + 1.2.0 3.1.3 2.2.3 3.3.1 @@ -163,24 +163,6 @@ org.apache.hugegraph hugegraph-common ${hugegraph.common.version} - - - org.glassfish.jersey.core - jersey-client - - - org.glassfish.jersey.media - jersey-media-json-jackson - - - org.glassfish.jersey.connectors - jersey-apache-connector - - - org.glassfish.jersey.inject - jersey-hk2 - - From 6bc34d61e8d81d53540dec83e78b6b4f2c97761e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Wed, 22 Nov 2023 22:20:05 +0800 Subject: [PATCH 23/53] fix --- .github/workflows/client-ci.yml | 10 +++++----- .github/workflows/hubble-ci.yml | 12 ++++++------ .github/workflows/loader-ci.yml | 10 +++++----- .github/workflows/spark-connector-ci.yml | 10 +++++----- .github/workflows/tools-ci.yml | 8 ++++---- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/client-ci.yml b/.github/workflows/client-ci.yml index b577a920f..e414921d1 100644 --- a/.github/workflows/client-ci.yml +++ b/.github/workflows/client-ci.yml @@ -42,17 +42,17 @@ jobs: key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 2 + - name: Use staged maven repo if: ${{ env.USE_STAGE == 'true' }} run: | cp $HOME/.m2/settings.xml /tmp/settings.xml mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 2 - - name: Compile run: | mvn -e compile -pl hugegraph-client -Dmaven.javadoc.skip=true -ntp diff --git a/.github/workflows/hubble-ci.yml b/.github/workflows/hubble-ci.yml index cbbdfcca7..c07078c1a 100644 --- a/.github/workflows/hubble-ci.yml +++ b/.github/workflows/hubble-ci.yml @@ -50,12 +50,6 @@ jobs: restore-keys: | ${{ runner.os }}-maven- - - name: use staged maven repo settings - if: ${{ env.USE_STAGE == 'true' }} - run: | - cp $HOME/.m2/settings.xml /tmp/settings.xml - mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml - - name: Get Yarn path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" @@ -83,6 +77,12 @@ jobs: with: fetch-depth: 2 + - name: use staged maven repo settings + if: ${{ env.USE_STAGE == 'true' }} + run: | + cp $HOME/.m2/settings.xml /tmp/settings.xml + mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml + - name: Compile run: | mvn install -pl hugegraph-client,hugegraph-loader -am -Dmaven.javadoc.skip=true -DskipTests -ntp diff --git a/.github/workflows/loader-ci.yml b/.github/workflows/loader-ci.yml index 6fdd29ffe..5789604b7 100644 --- a/.github/workflows/loader-ci.yml +++ b/.github/workflows/loader-ci.yml @@ -43,17 +43,17 @@ jobs: key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 2 + - name: use staged maven repo settings if: ${{ env.USE_STAGE == 'true' }} run: | cp $HOME/.m2/settings.xml /tmp/settings.xml mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 2 - - name: Compile run: | mvn install -pl hugegraph-client,hugegraph-loader -am -Dmaven.javadoc.skip=true -DskipTests -ntp diff --git a/.github/workflows/spark-connector-ci.yml b/.github/workflows/spark-connector-ci.yml index 4637a7e46..1b23c1fe1 100644 --- a/.github/workflows/spark-connector-ci.yml +++ b/.github/workflows/spark-connector-ci.yml @@ -39,17 +39,17 @@ jobs: key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: use staged maven repo settings if: ${{ env.USE_STAGE == 'true' }} run: | cp $HOME/.m2/settings.xml /tmp/settings.xml mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - name: Compile run: | mvn install -pl hugegraph-spark-connector -Dmaven.javadoc.skip=true -DskipTests -ntp diff --git a/.github/workflows/tools-ci.yml b/.github/workflows/tools-ci.yml index d88e310cc..c9531e581 100644 --- a/.github/workflows/tools-ci.yml +++ b/.github/workflows/tools-ci.yml @@ -37,15 +37,15 @@ jobs: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 2 - name: use staged maven repo settings if: ${{ env.USE_STAGE == 'true' }} run: | cp $HOME/.m2/settings.xml /tmp/settings.xml mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 2 - name: Compile run: | mvn install -pl hugegraph-client,hugegraph-tools -am -Dmaven.javadoc.skip=true -DskipTests -ntp From c637fcddb6a6f2e7adb7f2ee6dfd92d65aa81ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Wed, 22 Nov 2023 22:41:39 +0800 Subject: [PATCH 24/53] fix --- .github/workflows/license-checker.yml | 2 ++ .github/workflows/loader-ci.yml | 2 +- .github/workflows/spark-connector-ci.yml | 2 +- .github/workflows/tools-ci.yml | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/license-checker.yml b/.github/workflows/license-checker.yml index fa3e7e775..4acfad891 100644 --- a/.github/workflows/license-checker.yml +++ b/.github/workflows/license-checker.yml @@ -30,6 +30,8 @@ on: jobs: check-license-header: runs-on: ubuntu-latest + env: + USE_STAGE: 'true' # Whether to include the stage repository. steps: - uses: actions/checkout@v3 # More info could refer to: https://github.com/apache/skywalking-eyes diff --git a/.github/workflows/loader-ci.yml b/.github/workflows/loader-ci.yml index 50833a29c..a3752e248 100644 --- a/.github/workflows/loader-ci.yml +++ b/.github/workflows/loader-ci.yml @@ -23,7 +23,7 @@ jobs: loader-ci: runs-on: ubuntu-latest env: - SE_STAGE: 'true' # Whether to include the stage repository. + USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-loader/assembly/travis STATIC_DIR: hugegraph-loader/assembly/static COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314 diff --git a/.github/workflows/spark-connector-ci.yml b/.github/workflows/spark-connector-ci.yml index 1b23c1fe1..f398529a4 100644 --- a/.github/workflows/spark-connector-ci.yml +++ b/.github/workflows/spark-connector-ci.yml @@ -22,7 +22,7 @@ jobs: spark-connector-ci: runs-on: ubuntu-latest env: - SE_STAGE: 'true' # Whether to include the stage repository. + USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-spark-connector/assembly/travis VERSION_ID: 1.0.0 steps: diff --git a/.github/workflows/tools-ci.yml b/.github/workflows/tools-ci.yml index f9aa595c9..8db02af7c 100644 --- a/.github/workflows/tools-ci.yml +++ b/.github/workflows/tools-ci.yml @@ -22,7 +22,7 @@ jobs: tools-ci: runs-on: ubuntu-latest env: - SE_STAGE: 'true' # Whether to include the stage repository. + USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-tools/assembly/travis # TODO: could we use one param to unify it? or use a action template (could use one ci file) COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314 From f45f17647171a325d919a908b49edd7dca1242fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Wed, 22 Nov 2023 23:20:18 +0800 Subject: [PATCH 25/53] update version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 73b5ee716..385dc4c69 100644 --- a/pom.xml +++ b/pom.xml @@ -97,7 +97,7 @@ - 1.0.0 + 1.2.0 ${project.artifactId} apache-${release.name}-incubating-${project.version} ${project.basedir}/assembly From 150bb0eafae79776077626c3e86c4b7f0ace472f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Wed, 22 Nov 2023 23:23:05 +0800 Subject: [PATCH 26/53] fix spark-connector-ci --- .github/workflows/spark-connector-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/spark-connector-ci.yml b/.github/workflows/spark-connector-ci.yml index f398529a4..0eb06abf1 100644 --- a/.github/workflows/spark-connector-ci.yml +++ b/.github/workflows/spark-connector-ci.yml @@ -52,7 +52,8 @@ jobs: - name: Compile run: | - mvn install -pl hugegraph-spark-connector -Dmaven.javadoc.skip=true -DskipTests -ntp + mvn install -pl hugegraph-client,hugegraph-spark-connector -Dmaven.javadoc.skip=true + -DskipTests -ntp - name: Prepare env and service run: | From 75ff6d136af67794e53deb1fc9ee89b1669aaac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Thu, 23 Nov 2023 00:18:12 +0800 Subject: [PATCH 27/53] fix spark-connector-ci --- .github/workflows/spark-connector-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/spark-connector-ci.yml b/.github/workflows/spark-connector-ci.yml index 0eb06abf1..201d67c2c 100644 --- a/.github/workflows/spark-connector-ci.yml +++ b/.github/workflows/spark-connector-ci.yml @@ -52,8 +52,7 @@ jobs: - name: Compile run: | - mvn install -pl hugegraph-client,hugegraph-spark-connector -Dmaven.javadoc.skip=true - -DskipTests -ntp + mvn install -pl hugegraph-client,hugegraph-spark-connector -Dmaven.javadoc.skip=true -DskipTests -ntp - name: Prepare env and service run: | From 57e4d76959a97f7fbba8402406c8c594208f96ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Thu, 23 Nov 2023 00:27:27 +0800 Subject: [PATCH 28/53] fix spark-connector-ci --- .github/workflows/spark-connector-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spark-connector-ci.yml b/.github/workflows/spark-connector-ci.yml index 201d67c2c..c5b312bc2 100644 --- a/.github/workflows/spark-connector-ci.yml +++ b/.github/workflows/spark-connector-ci.yml @@ -52,7 +52,7 @@ jobs: - name: Compile run: | - mvn install -pl hugegraph-client,hugegraph-spark-connector -Dmaven.javadoc.skip=true -DskipTests -ntp + mvn install -pl hugegraph-client,hugegraph-spark-connector -am -Dmaven.javadoc.skip=true -DskipTests -ntp - name: Prepare env and service run: | From fcd0735c6e5f40adbfc56d074a6b61fee337e871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Thu, 23 Nov 2023 00:33:06 +0800 Subject: [PATCH 29/53] update client version --- hugegraph-spark-connector/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hugegraph-spark-connector/pom.xml b/hugegraph-spark-connector/pom.xml index 3a717c752..6f98f4b30 100644 --- a/hugegraph-spark-connector/pom.xml +++ b/hugegraph-spark-connector/pom.xml @@ -36,7 +36,7 @@ UTF-8 3.2.2 provided - 1.0.0 + 1.2.0 2.12.3 From 82b401a44f5e585a485ac8cfaa607d58c6ecca17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Thu, 23 Nov 2023 00:40:09 +0800 Subject: [PATCH 30/53] update client version --- hugegraph-spark-connector/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hugegraph-spark-connector/pom.xml b/hugegraph-spark-connector/pom.xml index 6f98f4b30..d93328c70 100644 --- a/hugegraph-spark-connector/pom.xml +++ b/hugegraph-spark-connector/pom.xml @@ -36,7 +36,7 @@ UTF-8 3.2.2 provided - 1.2.0 + 2.12.3 @@ -91,7 +91,7 @@ org.apache.hugegraph hugegraph-client - ${hugegraph.client.version} + ${revision} From ea06f2c0c50ac21c2b2b3bdafd656e50ff10b082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Thu, 23 Nov 2023 20:24:58 +0800 Subject: [PATCH 31/53] fix license-checker --- .github/workflows/license-checker.yml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/license-checker.yml b/.github/workflows/license-checker.yml index 540de04e6..77a51fe62 100644 --- a/.github/workflows/license-checker.yml +++ b/.github/workflows/license-checker.yml @@ -30,7 +30,7 @@ jobs: check-license-header: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # More info could refer to: https://github.com/apache/skywalking-eyes - name: Check License Header uses: apache/skywalking-eyes@main @@ -40,16 +40,6 @@ jobs: log: info config: .licenserc.yaml - - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - - - name: Use Node.js 16 - uses: actions/setup-node@v3 - with: - node-version: '16' - - name: License check(RAT) run: | mvn apache-rat:check -ntp @@ -60,9 +50,10 @@ jobs: runs-on: ubuntu-latest env: SCRIPT_DEPENDENCY: hugegraph-dist/scripts/dependency + USE_STAGE: 'true' # Whether to include the stage repository. steps: - name: Checkout source - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up JDK 11 uses: actions/setup-java@v3 with: @@ -72,6 +63,13 @@ jobs: uses: actions/setup-node@v3 with: node-version: '16' + + - name: use staged maven repo settings + if: ${{ env.USE_STAGE == 'true' }} + run: | + cp $HOME/.m2/settings.xml /tmp/settings.xml + mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml + - name: mvn install run: | mvn install -DskipTests=true -ntp From 49a2343ca59fc7d98da0001a3e075b993683f64e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Thu, 23 Nov 2023 20:44:11 +0800 Subject: [PATCH 32/53] code optimize --- hugegraph-client/pom.xml | 18 ------------------ hugegraph-hubble/pom.xml | 7 ------- hugegraph-spark-connector/pom.xml | 31 ------------------------------- pom.xml | 8 -------- 4 files changed, 64 deletions(-) diff --git a/hugegraph-client/pom.xml b/hugegraph-client/pom.xml index c8186ddf9..53e5eab3d 100644 --- a/hugegraph-client/pom.xml +++ b/hugegraph-client/pom.xml @@ -45,24 +45,6 @@ org.apache.hugegraph hugegraph-common - - - org.glassfish.jersey.core - jersey-client - - - org.glassfish.jersey.media - jersey-media-json-jackson - - - org.glassfish.jersey.connectors - jersey-apache-connector - - - org.glassfish.jersey.inject - jersey-hk2 - - org.lz4 diff --git a/hugegraph-hubble/pom.xml b/hugegraph-hubble/pom.xml index ca80db511..5f49b717e 100644 --- a/hugegraph-hubble/pom.xml +++ b/hugegraph-hubble/pom.xml @@ -47,13 +47,6 @@ - - - - - - - com.fasterxml.jackson jackson-bom diff --git a/hugegraph-spark-connector/pom.xml b/hugegraph-spark-connector/pom.xml index d93328c70..cfac9550a 100644 --- a/hugegraph-spark-connector/pom.xml +++ b/hugegraph-spark-connector/pom.xml @@ -38,8 +38,6 @@ provided 2.12.3 - - 2.18.0 1.7.25 2.12.11 @@ -94,35 +92,6 @@ ${revision} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - com.fasterxml.jackson.jaxrs diff --git a/pom.xml b/pom.xml index 385dc4c69..b31cfa499 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,6 @@ 2.2.3 3.3.1 3.6.2 - 4.12 2.8.47 1.18.8 @@ -152,13 +151,6 @@ - - - - - - - org.apache.hugegraph hugegraph-common From f0db02a8053e05a6334d253375e94dbb1c0de0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Thu, 23 Nov 2023 20:48:54 +0800 Subject: [PATCH 33/53] remove useless dependency --- hugegraph-client/pom.xml | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/hugegraph-client/pom.xml b/hugegraph-client/pom.xml index 53e5eab3d..98c4eff8e 100644 --- a/hugegraph-client/pom.xml +++ b/hugegraph-client/pom.xml @@ -38,7 +38,6 @@ 1.18.8 - 4.10.0 @@ -56,36 +55,14 @@ test - - com.squareup.okhttp3 - okhttp - - - com.squareup.okhttp3 - logging-interceptor - - org.projectlombok lombok ${lombok.version} true - - - - - com.squareup.okhttp3 - okhttp-bom - ${okhttp.version} - pom - import - - - - From e5930089db19fb58ac3ed801fd201cb9ca373341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Thu, 23 Nov 2023 21:32:33 +0800 Subject: [PATCH 34/53] remove useless code --- .../java/org/apache/hugegraph/api/auth/UserAPI.java | 1 - .../java/org/apache/hugegraph/api/graph/GraphAPI.java | 10 ---------- hugegraph-spark-connector/pom.xml | 1 - 3 files changed, 12 deletions(-) diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java index 5b1ea3254..f78ebba1c 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java @@ -50,7 +50,6 @@ public User get(Object id) { } public UserRole getUserRole(Object id) { -// String idEncoded = RestClient.encode(formatEntityId(id)); String idEncoded = formatEntityId(id); String path = String.join("/", this.path(), idEncoded, "role"); RestResult result = this.client.get(path); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java index d76929dc2..fb0a638e0 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java @@ -68,16 +68,6 @@ public static String formatProperties(Map properties) { return null; } String json = JsonUtil.toJson(properties); - /* - * Don't use UrlEncoder.encode, it encoded the space as `+`, - * which will invalidate the jersey's automatic decoding - * because it considers the space to be encoded as `%2F` - */ -// return encode(json); return json; } - -// public static String encode(String raw) { -// return UriComponent.encode(raw, Type.QUERY_PARAM_SPACE_ENCODED); -// } } diff --git a/hugegraph-spark-connector/pom.xml b/hugegraph-spark-connector/pom.xml index cfac9550a..b5e249b07 100644 --- a/hugegraph-spark-connector/pom.xml +++ b/hugegraph-spark-connector/pom.xml @@ -36,7 +36,6 @@ UTF-8 3.2.2 provided - 2.12.3 2.18.0 1.7.25 From 3eb6c42f0ab41bcce503c0de627da5a828714da4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Thu, 23 Nov 2023 22:07:19 +0800 Subject: [PATCH 35/53] fix licence check --- hugegraph-dist/scripts/dependency/known-dependencies.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/hugegraph-dist/scripts/dependency/known-dependencies.txt b/hugegraph-dist/scripts/dependency/known-dependencies.txt index 3326845ee..83add0d23 100644 --- a/hugegraph-dist/scripts/dependency/known-dependencies.txt +++ b/hugegraph-dist/scripts/dependency/known-dependencies.txt @@ -138,7 +138,6 @@ jersey-container-servlet-core-2.27.jar javax.inject-2.5.0-b32.jar javax.inject-2.5.0-b42.jar jakarta.xml.bind-api-2.3.2.jar -jakarta.xml.bind-api-4.0.0-RC2.jar jamon-runtime-2.4.1.jar javassist-3.24.0-GA.jar javassist-3.25.0-GA.jar From cda3e2887749a1a8b0670bd42ae200c40a267bcb Mon Sep 17 00:00:00 2001 From: imbajin Date: Fri, 24 Nov 2023 12:38:56 +0800 Subject: [PATCH 36/53] fix import & update api version --- .../apache/hugegraph/api/graph/EdgeAPI.java | 15 ++---- .../apache/hugegraph/api/graph/GraphAPI.java | 6 +-- .../apache/hugegraph/api/graph/VertexAPI.java | 10 ++-- .../hugegraph/api/graphs/GraphsAPI.java | 12 ++--- .../apache/hugegraph/client/RestClient.java | 13 +++-- .../apache/hugegraph/driver/HugeClient.java | 8 +-- .../apache/hugegraph/unit/RestResultTest.java | 49 +++++++------------ pom.xml | 5 +- 8 files changed, 48 insertions(+), 70 deletions(-) diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java index 64ef0b312..36c3eb19b 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java @@ -21,7 +21,6 @@ import java.util.List; import java.util.Map; -import okhttp3.Headers; import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.NotAllCreatedException; import org.apache.hugegraph.rest.RestHeaders; @@ -52,10 +51,8 @@ public Edge create(Edge edge) { public List create(List edges, boolean checkVertex) { RestHeaders headers = new RestHeaders().add(RestHeaders.CONTENT_ENCODING, BATCH_ENCODING); - Map params = ImmutableMap.of("check_vertex", - checkVertex); - RestResult result = this.client.post(this.batchPath(), edges, - headers, params); + Map params = ImmutableMap.of("check_vertex", checkVertex); + RestResult result = this.client.post(this.batchPath(), edges, headers, params); List ids = result.readList(String.class); if (edges.size() != ids.size()) { throw new NotAllCreatedException("Not all edges are successfully created, " + @@ -95,11 +92,9 @@ public Edges list(int limit) { return this.list(null, null, null, null, 0, null, limit); } - public Edges list(Object vertexId, Direction direction, - String label, Map properties, - int offset, String page, int limit) { - return this.list(vertexId, direction, label, properties, false, - offset, page, limit); + public Edges list(Object vertexId, Direction direction, String label, + Map properties, int offset, String page, int limit) { + return this.list(vertexId, direction, label, properties, false, offset, page, limit); } public Edges list(Object vertexId, Direction direction, String label, diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java index fb0a638e0..c2eb76819 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java @@ -58,8 +58,7 @@ public static String formatVertexId(Object id, boolean allowNull) { id = id.toString(); } E.checkArgument(id instanceof String || id instanceof Number, - "The vertex id must be either String or " + - "Number, but got '%s'", id); + "The vertex id must be either String or Number, but got '%s'", id); return (uuid ? "U" : "") + JsonUtil.toJson(id); } @@ -67,7 +66,6 @@ public static String formatProperties(Map properties) { if (properties == null) { return null; } - String json = JsonUtil.toJson(properties); - return json; + return JsonUtil.toJson(properties); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java index 61ebc1461..70f4de78a 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java @@ -17,8 +17,10 @@ package org.apache.hugegraph.api.graph; -import com.google.common.collect.ImmutableMap; -import okhttp3.Headers; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + import org.apache.hugegraph.client.RestClient; import org.apache.hugegraph.exception.InvalidResponseException; import org.apache.hugegraph.exception.NotAllCreatedException; @@ -30,9 +32,7 @@ import org.apache.hugegraph.structure.graph.Vertex; import org.apache.hugegraph.structure.graph.Vertices; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import com.google.common.collect.ImmutableMap; public class VertexAPI extends GraphAPI { diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java index 851153cad..3a85c3d82 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java @@ -17,8 +17,9 @@ package org.apache.hugegraph.api.graphs; -import com.google.common.collect.ImmutableMap; -import okhttp3.Headers; +import java.util.List; +import java.util.Map; + import org.apache.commons.lang3.StringUtils; import org.apache.hugegraph.api.API; import org.apache.hugegraph.client.RestClient; @@ -29,8 +30,7 @@ import org.apache.hugegraph.structure.constant.GraphReadMode; import org.apache.hugegraph.structure.constant.HugeType; -import java.util.List; -import java.util.Map; +import com.google.common.collect.ImmutableMap; public class GraphsAPI extends API { @@ -38,7 +38,6 @@ public class GraphsAPI extends API { private static final String MODE = "mode"; private static final String GRAPH_READ_MODE = "graph_read_mode"; private static final String CLEAR = "clear"; - private static final String CONFIRM_MESSAGE = "confirm_message"; public GraphsAPI(RestClient client) { @@ -113,8 +112,7 @@ public void readMode(String graph, GraphReadMode readMode) { // NOTE: Must provide id for PUT. If use "graph/graph_read_mode", "/" // will be encoded to "%2F". So use "graph_read_mode" here although // inaccurate. - this.client.put(joinPath(this.path(), graph, GRAPH_READ_MODE), - null, readMode); + this.client.put(joinPath(this.path(), graph, GRAPH_READ_MODE), null, readMode); } public GraphReadMode readMode(String graph) { diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java index d54a1f5d9..508537f3b 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java @@ -17,19 +17,20 @@ package org.apache.hugegraph.client; -import okhttp3.Response; import org.apache.hugegraph.exception.ServerException; -import org.apache.hugegraph.serializer.PathDeserializer; -import org.apache.hugegraph.structure.graph.Path; import org.apache.hugegraph.rest.AbstractRestClient; import org.apache.hugegraph.rest.ClientException; import org.apache.hugegraph.rest.RestResult; +import org.apache.hugegraph.serializer.PathDeserializer; +import org.apache.hugegraph.structure.graph.Path; import org.apache.hugegraph.util.E; import org.apache.hugegraph.util.VersionUtil; import org.apache.hugegraph.util.VersionUtil.Version; import com.fasterxml.jackson.databind.module.SimpleModule; +import okhttp3.Response; + public class RestClient extends AbstractRestClient { private static final int SECOND = 1000; @@ -42,8 +43,7 @@ public class RestClient extends AbstractRestClient { RestResult.registerModule(module); } - public RestClient(String url, String username, String password, - int timeout) { + public RestClient(String url, String username, String password, int timeout) { super(url, username, password, timeout * SECOND); } @@ -72,8 +72,7 @@ public void checkApiVersion(String minVersion, String message) { } public boolean apiVersionLt(String minVersion) { - String apiVersion = this.apiVersion == null ? - null : this.apiVersion.get(); + String apiVersion = this.apiVersion == null ? null : this.apiVersion.get(); return apiVersion != null && !VersionUtil.gte(apiVersion, minVersion); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java index ff525f71e..4eacf15ae 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java @@ -19,12 +19,12 @@ import java.io.Closeable; -import lombok.extern.slf4j.Slf4j; -import org.apache.hugegraph.version.ClientVersion; import org.apache.hugegraph.client.RestClient; - import org.apache.hugegraph.rest.ClientException; import org.apache.hugegraph.util.VersionUtil; +import org.apache.hugegraph.version.ClientVersion; + +import lombok.extern.slf4j.Slf4j; @Slf4j public class HugeClient implements Closeable { @@ -110,7 +110,7 @@ private void initManagers(RestClient client, String graph) { private void checkServerApiVersion() { VersionUtil.Version apiVersion = VersionUtil.Version.of(this.version.getApiVersion()); - VersionUtil.check(apiVersion, "0.38", "0.70", "hugegraph-api in server"); + VersionUtil.check(apiVersion, "0.38", "0.72", "hugegraph-api in server"); this.client.apiVersion(apiVersion); } diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java index d13b7224e..518552d3f 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java @@ -22,7 +22,6 @@ import java.util.Iterator; import java.util.List; -import lombok.SneakyThrows; import org.apache.hugegraph.driver.GraphManager; import org.apache.hugegraph.rest.RestHeaders; import org.apache.hugegraph.rest.RestResult; @@ -55,6 +54,8 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import lombok.SneakyThrows; + public class RestResultTest extends BaseUnitTest { private okhttp3.Response mockResponse; @@ -131,14 +132,12 @@ public void testReadPropertyKeys() { Mockito.when(this.mockResponse.code()).thenReturn(200); Mockito.when(this.mockResponse.headers()).thenReturn(null); - Mockito.when(this.mockResponse.body().string()) - .thenReturn(json); + Mockito.when(this.mockResponse.body().string()).thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); Assert.assertEquals(result.headers(), new RestHeaders()); - List propertyKeys = result.readList("propertykeys", - PropertyKey.class); + List propertyKeys = result.readList("propertykeys", PropertyKey.class); Assert.assertEquals(2, propertyKeys.size()); PropertyKey propertyKey1 = propertyKeys.get(0); PropertyKey propertyKey2 = propertyKeys.get(1); @@ -168,8 +167,7 @@ public void testReadVertexLabel() { Mockito.when(this.mockResponse.code()).thenReturn(200); Mockito.when(this.mockResponse.headers()).thenReturn(null); - Mockito.when(this.mockResponse.body().string()) - .thenReturn(json); + Mockito.when(this.mockResponse.body().string()).thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); Assert.assertEquals(result.headers(), new RestHeaders()); @@ -178,10 +176,8 @@ public void testReadVertexLabel() { Assert.assertEquals("software", vertexLabel.name()); Assert.assertEquals(IdStrategy.PRIMARY_KEY, vertexLabel.idStrategy()); - Assert.assertEquals(ImmutableList.of("name"), - vertexLabel.primaryKeys()); - Assert.assertEquals(ImmutableSet.of("price", "name", "lang"), - vertexLabel.properties()); + Assert.assertEquals(ImmutableList.of("name"), vertexLabel.primaryKeys()); + Assert.assertEquals(ImmutableSet.of("price", "name", "lang"), vertexLabel.properties()); } @SneakyThrows @@ -208,31 +204,25 @@ public void testReadVertexLabels() { Mockito.when(this.mockResponse.code()).thenReturn(200); Mockito.when(this.mockResponse.headers()).thenReturn(null); - Mockito.when(this.mockResponse.body().string()) - .thenReturn(json); + Mockito.when(this.mockResponse.body().string()).thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); Assert.assertEquals(result.headers(), new RestHeaders()); - List vertexLabels = result.readList("vertexlabels", - VertexLabel.class); + List vertexLabels = result.readList("vertexlabels", VertexLabel.class); Assert.assertEquals(2, vertexLabels.size()); VertexLabel vertexLabel1 = vertexLabels.get(0); VertexLabel vertexLabel2 = vertexLabels.get(1); Assert.assertEquals("software", vertexLabel1.name()); Assert.assertEquals(IdStrategy.PRIMARY_KEY, vertexLabel1.idStrategy()); - Assert.assertEquals(ImmutableList.of("name"), - vertexLabel1.primaryKeys()); - Assert.assertEquals(ImmutableSet.of("price", "name", "lang"), - vertexLabel1.properties()); + Assert.assertEquals(ImmutableList.of("name"), vertexLabel1.primaryKeys()); + Assert.assertEquals(ImmutableSet.of("price", "name", "lang"), vertexLabel1.properties()); Assert.assertEquals("person", vertexLabel2.name()); Assert.assertEquals(IdStrategy.CUSTOMIZE_STRING, vertexLabel2.idStrategy()); - Assert.assertEquals(Collections.emptyList(), - vertexLabel2.primaryKeys()); - Assert.assertEquals(ImmutableSet.of("city", "name", "age"), - vertexLabel2.properties()); + Assert.assertEquals(Collections.emptyList(), vertexLabel2.primaryKeys()); + Assert.assertEquals(ImmutableSet.of("city", "name", "age"), vertexLabel2.properties()); } @SneakyThrows @@ -251,8 +241,7 @@ public void testReadEdgeLabel() { Mockito.when(this.mockResponse.code()).thenReturn(200); Mockito.when(this.mockResponse.headers()).thenReturn(null); - Mockito.when(this.mockResponse.body().string()) - .thenReturn(json); + Mockito.when(this.mockResponse.body().string()).thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); Assert.assertEquals(result.headers(), new RestHeaders()); @@ -531,7 +520,7 @@ public void testReadEdge() { .thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); - Assert.assertEquals(result.headers(), new RestHeaders()); + Assert.assertEquals(result.headers(), new RestHeaders()); Edge edge = result.readObject(Edge.class); @@ -541,8 +530,7 @@ public void testReadEdge() { Assert.assertEquals("software:lop", edge.targetId()); Assert.assertEquals("person", edge.sourceLabel()); Assert.assertEquals("software", edge.targetLabel()); - Assert.assertEquals(ImmutableMap.of("city", "Hongkong", - "date", 1495036800000L), + Assert.assertEquals(ImmutableMap.of("city", "Hongkong", "date", 1495036800000L), edge.properties()); } @@ -583,7 +571,7 @@ public void testReadEdges() { .thenReturn(json); RestResult result = new RestResult(this.mockResponse); Assert.assertEquals(200, result.status()); - Assert.assertEquals(result.headers(), new RestHeaders()); + Assert.assertEquals(result.headers(), new RestHeaders()); List edges = result.readList("edges", Edge.class); Assert.assertEquals(2, edges.size()); @@ -1027,8 +1015,7 @@ public void testReadGremlinEdgeAndNull() { created.targetLabel("software"); created.property("date", 1490284800000L); created.property("weight", 0.2); - Assert.assertTrue(Utils.contains(ImmutableList.of(created), - result.getEdge())); + Assert.assertTrue(Utils.contains(ImmutableList.of(created), result.getEdge())); Assert.assertTrue(results.hasNext()); result = results.next(); diff --git a/pom.xml b/pom.xml index b31cfa499..ed3aa7c87 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,8 @@ ${project.artifactId} https://github.com/apache/incubator-hugegraph-toolchain - hugegraph-toolchain is the integration project of a series of utilities for HugeGraph, it includes 4 main modules (loader/hubble/tools/client) + hugegraph-toolchain is the integration project of a series of utilities for HugeGraph, + it includes 4 main modules (loader/hubble/tools/client) @@ -98,6 +99,7 @@ 1.2.0 + 1.2.0 ${project.artifactId} apache-${release.name}-incubating-${project.version} ${project.basedir}/assembly @@ -120,7 +122,6 @@ hugegraph ${project.name} ${project.version} - 1.2.0 3.1.3 2.2.3 3.3.1 From e03074c13daf6beb0846ad9f2e2947e69050c6fa Mon Sep 17 00:00:00 2001 From: imbajin Date: Fri, 24 Nov 2023 13:05:52 +0800 Subject: [PATCH 37/53] remove redundant common import in hubble --- hugegraph-client/pom.xml | 3 +- hugegraph-hubble/hubble-be/pom.xml | 47 ++++++++---------------------- hugegraph-hubble/pom.xml | 2 +- hugegraph-loader/pom.xml | 7 +++-- 4 files changed, 18 insertions(+), 41 deletions(-) diff --git a/hugegraph-client/pom.xml b/hugegraph-client/pom.xml index 98c4eff8e..f94f94544 100644 --- a/hugegraph-client/pom.xml +++ b/hugegraph-client/pom.xml @@ -30,7 +30,7 @@ jar ${project.artifactId} - https://github.com/apache/incubator-hugegraph-toolchain/tree/master/hugegraph-client + https://github.com/apache/hugegraph-toolchain/tree/master/hugegraph-client hugegraph-client is a Java-written client of HugeGraph, providing operations of graph, schema, gremlin, variables and traversals etc. @@ -54,7 +54,6 @@ mockito-core test - org.projectlombok lombok diff --git a/hugegraph-hubble/hubble-be/pom.xml b/hugegraph-hubble/hubble-be/pom.xml index d07f7d824..f13e47ee2 100644 --- a/hugegraph-hubble/hubble-be/pom.xml +++ b/hugegraph-hubble/hubble-be/pom.xml @@ -1,17 +1,19 @@ com.github.ben-manes.caffeine caffeine - - org.apache.hugegraph - hugegraph-common - - - org.glassfish.jersey.core - jersey-client - - - org.glassfish.jersey.media - jersey-media-json-jackson - - - org.glassfish.jersey.connectors - jersey-apache-connector - - - org.glassfish.jersey.inject - jersey-hk2 - - - org.apache.hugegraph @@ -146,10 +126,6 @@ com.oracle ojdbc8 - - org.apache.hugegraph - hugegraph-common - slf4j-log4j12 org.slf4j @@ -168,6 +144,7 @@ + com.squareup.okhttp3 okhttp diff --git a/hugegraph-hubble/pom.xml b/hugegraph-hubble/pom.xml index 5f49b717e..5af407abc 100644 --- a/hugegraph-hubble/pom.xml +++ b/hugegraph-hubble/pom.xml @@ -30,7 +30,7 @@ pom ${project.artifactId} - https://github.com/apache/incubator-hugegraph-toolchain/tree/master/hugegraph-hubble + https://github.com/apache/hugegraph-toolchain/tree/master/hugegraph-hubble hugegraph-hubble is a graph management and analysis platform that provides features: graph data load, schema management, graph relationship analysis and graphical display. diff --git a/hugegraph-loader/pom.xml b/hugegraph-loader/pom.xml index e6d121bef..e4565f0f7 100644 --- a/hugegraph-loader/pom.xml +++ b/hugegraph-loader/pom.xml @@ -30,11 +30,11 @@ jar ${project.artifactId} - https://github.com/apache/incubator-hugegraph-toolchain/tree/master/hugegraph-loader + https://github.com/apache/hugegraph-toolchain/tree/master/hugegraph-loader hugegraph-loader is a customizable command line utility for loading small to medium size - graph datasets - into the HugeGraph database from multiple data sources with various input formats. + graph datasets into the HugeGraph database from multiple data sources with various + input formats. @@ -366,6 +366,7 @@ hadoop-hdfs-client ${hadoop.version} + org.apache.hadoop hadoop-mapred From 76a85eee260ae5086d95ae1d2d16aa62f09447f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Fri, 24 Nov 2023 21:40:41 +0800 Subject: [PATCH 38/53] remove redundant lombok version --- hugegraph-client/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hugegraph-client/pom.xml b/hugegraph-client/pom.xml index f94f94544..4fe70d52e 100644 --- a/hugegraph-client/pom.xml +++ b/hugegraph-client/pom.xml @@ -15,8 +15,8 @@ License for the specific language governing permissions and limitations under the License. --> - 4.0.0 @@ -37,7 +37,7 @@ - 1.18.8 + From cdd10123c3f0f6b0d1c6d9c9162f3b1c91db9d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Fri, 24 Nov 2023 21:41:19 +0800 Subject: [PATCH 39/53] remove useless code --- hugegraph-client/pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hugegraph-client/pom.xml b/hugegraph-client/pom.xml index 4fe70d52e..08b8d3ebe 100644 --- a/hugegraph-client/pom.xml +++ b/hugegraph-client/pom.xml @@ -36,10 +36,6 @@ operations of graph, schema, gremlin, variables and traversals etc. - - - - org.apache.hugegraph From 30396fb4868a3f51aa5b7979237664763d47aa31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Fri, 24 Nov 2023 21:49:20 +0800 Subject: [PATCH 40/53] add comment --- hugegraph-hubble/hubble-be/pom.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hugegraph-hubble/hubble-be/pom.xml b/hugegraph-hubble/hubble-be/pom.xml index f13e47ee2..301c6c347 100644 --- a/hugegraph-hubble/hubble-be/pom.xml +++ b/hugegraph-hubble/hubble-be/pom.xml @@ -15,8 +15,8 @@ License for the specific language governing permissions and limitations under the License. --> - 4.0.0 @@ -145,6 +145,7 @@ + com.squareup.okhttp3 okhttp From d9603c0d71bccb4bfd87eb80b7c7185a27afeddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Sat, 25 Nov 2023 20:59:52 +0800 Subject: [PATCH 41/53] rename id --- .../src/main/java/org/apache/hugegraph/api/auth/UserAPI.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java index f78ebba1c..3c1c1d0c7 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java @@ -50,8 +50,8 @@ public User get(Object id) { } public UserRole getUserRole(Object id) { - String idEncoded = formatEntityId(id); - String path = String.join("/", this.path(), idEncoded, "role"); + String formattedId = formatEntityId(id); + String path = String.join("/", this.path(), formattedId, "role"); RestResult result = this.client.get(path); return result.readObject(UserRole.class); } From 0a09aac7772d5ba4bfe164954bb27a40422a01f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Sun, 26 Nov 2023 23:34:00 +0800 Subject: [PATCH 42/53] add encode test case --- .../org/apache/hugegraph/BaseClientTest.java | 27 +++-- .../hugegraph/api/auth/UserApiTest.java | 24 ++-- .../apache/hugegraph/functional/EdgeTest.java | 112 ++++++++++-------- 3 files changed, 89 insertions(+), 74 deletions(-) diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java index e195d12e8..f2215d49e 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java @@ -125,16 +125,6 @@ public static MetricsManager metrics() { return client.metrics(); } - @Before - public void setup() { - // this.clearData(); - } - - @After - public void teardown() throws Exception { - // pass - } - protected static Object getVertexId(String label, String key, String value) { return getVertex(label, key, value).id(); @@ -185,6 +175,7 @@ protected static void initPropertyKey() { schema.propertyKey("city").asText().ifNotExist().create(); schema.propertyKey("lang").asText().ifNotExist().create(); schema.propertyKey("date").asDate().ifNotExist().create(); + schema.propertyKey("date 2&@").asDate().ifNotExist().create(); schema.propertyKey("price").asInt().ifNotExist().create(); schema.propertyKey("weight").asDouble().ifNotExist().create(); } @@ -230,8 +221,8 @@ protected static void initEdgeLabel() { schema.edgeLabel("created") .sourceLabel("person") .targetLabel("software") - .properties("date", "city") - .nullableKeys("city") + .properties("date", "date 2&@", "city") + .nullableKeys("city", "date 2&@") .ifNotExist() .create(); } @@ -294,7 +285,7 @@ protected static void initEdge() { graph().addEdge(markoId, "knows", vadasId, "date", "2012-01-10"); graph().addEdge(markoId, "knows", joshId, "date", "2013-01-10"); graph().addEdge(markoId, "created", lopId, - "date", "2014-01-10", "city", "Shanghai"); + "date", "2014-01-10", "city", "Shanghai", "date 2&@", "2014-01-10"); graph().addEdge(joshId, "created", rippleId, "date", "2015-01-10", "city", "Beijing"); graph().addEdge(joshId, "created", lopId, @@ -303,6 +294,16 @@ protected static void initEdge() { "date", "2017-01-10", "city", "Hongkong"); } + @Before + public void setup() { + // this.clearData(); + } + + @After + public void teardown() throws Exception { + // pass + } + protected List create100PersonBatch() { List vertices = new ArrayList<>(100); for (int i = 0; i < 100; i++) { diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/UserApiTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/UserApiTest.java index f2533ab80..f0cfcc27a 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/UserApiTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/UserApiTest.java @@ -49,6 +49,16 @@ public static void clear() { } } + protected static User createUser(String name, String password) { + User user = new User(); + user.name(name); + user.password(password); + user.email("test@hugegraph.com"); + user.phone("16812345678"); + user.avatar("image.jpg"); + return api.create(user); + } + @Override @After public void teardown() { @@ -136,15 +146,19 @@ public void testGet() { public void testGetUserRole() { User user1 = createUser("test1", "psw1"); User user2 = createUser("test2", "psw2"); + User user3 = createUser("test3 aaa", "psw3"); Assert.assertEquals("test1", user1.name()); Assert.assertEquals("test2", user2.name()); + Assert.assertContains("test3 aaa", user3.name());//test special character UserRole role1 = api.getUserRole(user1.id()); UserRole role2 = api.getUserRole(user2.id()); + UserRole role3 = api.getUserRole(user3.id()); Assert.assertEquals("{\"roles\":{}}", role1.toString()); Assert.assertEquals("{\"roles\":{}}", role2.toString()); + Assert.assertEquals("{\"roles\":{}}", role3.toString()); } @Test @@ -256,14 +270,4 @@ public void testDelete() { Assert.assertContains("Invalid user id: fake-id", e.getMessage()); }); } - - protected static User createUser(String name, String password) { - User user = new User(); - user.name(name); - user.password(password); - user.email("test@hugegraph.com"); - user.phone("16812345678"); - user.avatar("image.jpg"); - return api.create(user); - } } diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java index 4de5c3af4..cdc6550d0 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java @@ -46,6 +46,21 @@ public class EdgeTest extends BaseFuncTest { + private static void assertContains(List edges, Object source, + String label, Object target, + Object... keyValues) { + Map properties = Utils.asMap(keyValues); + + Edge edge = new Edge(label); + edge.sourceId(source); + edge.targetId(target); + for (String key : properties.keySet()) { + edge.property(key, properties.get(key)); + } + + Assert.assertTrue(Utils.contains(edges, edge)); + } + @Override @Before public void setup() { @@ -80,7 +95,7 @@ public void testAddEdgeProperty() { Edge created = graph().addEdge(peterId, "created", lopId, "date", "2017-03-24"); Map props = ImmutableMap.of( - "date", Utils.formatDate("2017-03-24")); + "date", Utils.formatDate("2017-03-24")); Assert.assertEquals(props, created.properties()); created.property("city", "HongKong"); @@ -97,7 +112,7 @@ public void testUpdateEdgeProperty() { Edge created = graph().addEdge(peterId, "created", lopId, "date", "2017-03-24"); Map props = ImmutableMap.of( - "date", Utils.formatDate("2017-03-24")); + "date", Utils.formatDate("2017-03-24")); Assert.assertEquals(props, created.properties()); created.property("date", "2017-08-08"); @@ -125,16 +140,16 @@ public void testAddEdgePropertyValueList() { "time", "2012-10-10"); Map props = ImmutableMap.of( - "date", Utils.formatDate("2017-03-24"), - "time", ImmutableList.of( - Utils.formatDate("2012-10-10"))); + "date", Utils.formatDate("2017-03-24"), + "time", ImmutableList.of( + Utils.formatDate("2012-10-10"))); Assert.assertEquals(props, created.properties()); created.property("time", "2014-02-14"); props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"), "time", ImmutableList.of( - Utils.formatDate("2012-10-10"), - Utils.formatDate("2014-02-14"))); + Utils.formatDate("2012-10-10"), + Utils.formatDate("2014-02-14"))); Assert.assertEquals(props, created.properties()); } @@ -158,16 +173,16 @@ public void testAddEdgePropertyValueSet() { "time", "2012-10-10"); Map props = ImmutableMap.of( - "date", Utils.formatDate("2017-03-24"), - "time", ImmutableList.of( - Utils.formatDate("2012-10-10"))); + "date", Utils.formatDate("2017-03-24"), + "time", ImmutableList.of( + Utils.formatDate("2012-10-10"))); Assert.assertEquals(props, created.properties()); created.property("time", "2014-02-14"); props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"), "time", ImmutableList.of( - Utils.formatDate("2012-10-10"), - Utils.formatDate("2014-02-14"))); + Utils.formatDate("2012-10-10"), + Utils.formatDate("2014-02-14"))); Assert.assertEquals(props, created.properties()); } @@ -191,16 +206,16 @@ public void testAddEdgePropertyValueListWithSameValue() { "time", "2012-10-10"); Map props = ImmutableMap.of( - "date", Utils.formatDate("2017-03-24"), - "time", ImmutableList.of( - Utils.formatDate("2012-10-10"))); + "date", Utils.formatDate("2017-03-24"), + "time", ImmutableList.of( + Utils.formatDate("2012-10-10"))); Assert.assertEquals(props, created.properties()); created.property("time", "2012-10-10"); props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"), "time", ImmutableList.of( - Utils.formatDate("2012-10-10"), - Utils.formatDate("2012-10-10"))); + Utils.formatDate("2012-10-10"), + Utils.formatDate("2012-10-10"))); Assert.assertEquals(props, created.properties()); } @@ -224,15 +239,15 @@ public void testAddEdgePropertyValueSetWithSameValue() { "time", "2012-10-10"); Map props = ImmutableMap.of( - "date", Utils.formatDate("2017-03-24"), - "time", ImmutableList.of( - Utils.formatDate("2012-10-10"))); + "date", Utils.formatDate("2017-03-24"), + "time", ImmutableList.of( + Utils.formatDate("2012-10-10"))); Assert.assertEquals(props, created.properties()); created.property("time", "2012-10-10"); props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"), "time", ImmutableList.of( - Utils.formatDate("2012-10-10"))); + Utils.formatDate("2012-10-10"))); Assert.assertEquals(props, created.properties()); } @@ -245,8 +260,8 @@ public void testAddEdgeWithMapProperties() { "city", "HongKong"); Edge created = graph().addEdge(peter, "created", lop, properties); Map props = ImmutableMap.of( - "date", Utils.formatDate("2017-03-24"), - "city", "HongKong"); + "date", Utils.formatDate("2017-03-24"), + "city", "HongKong"); Assert.assertEquals(props, created.properties()); } @@ -270,9 +285,9 @@ public void testRemoveEdgeProperty() { "time", "2012-10-10"); Map props = ImmutableMap.of( - "date", Utils.formatDate("2017-03-24"), - "time", ImmutableList.of( - Utils.formatDate("2012-10-10"))); + "date", Utils.formatDate("2017-03-24"), + "time", ImmutableList.of( + Utils.formatDate("2012-10-10"))); Assert.assertEquals(props, created.properties()); created.removeProperty("time"); @@ -288,7 +303,7 @@ public void testRemoveEdgePropertyNotExist() { Edge created = graph().addEdge(peterId, "created", lopId, "date", "2017-03-24"); Map props = ImmutableMap.of( - "date", Utils.formatDate("2017-03-24")); + "date", Utils.formatDate("2017-03-24")); Assert.assertEquals(props, created.properties()); Assert.assertThrows(InvalidOperationException.class, () -> { @@ -511,8 +526,8 @@ public void testGetEdgesByVertexIdDirectionLabelProperties() { Object rippleId = getVertexId("software", "name", "ripple"); Map properties = ImmutableMap.of( - "date", - Utils.formatDate("2015-01-10")); + "date", + Utils.formatDate("2015-01-10")); List edges = graph().getEdges(joshId, Direction.OUT, "created", properties); Assert.assertEquals(1, edges.size()); @@ -534,8 +549,8 @@ public void testGetEdgesByVertexIdDirectionLabelPropertiesWithLimit1() { Object joshId = getVertexId("person", "name", "josh"); Map properties = ImmutableMap.of( - "date", - Utils.formatDate("2015-01-10")); + "date", + Utils.formatDate("2015-01-10")); List edges = graph().getEdges(joshId, Direction.OUT, "created", properties); Assert.assertEquals(1, edges.size()); @@ -555,7 +570,7 @@ public void testGetEdgesByVertexIdDirectionLabelPropertiesWithLimit1() { @Test public void testGetEdgesByLabelAndPropertiesWithRangeCondition() - throws ParseException { + throws ParseException { schema().indexLabel("knowsByDate").range() .onE("knows").by("date").create(); schema().indexLabel("createdByDate").range() @@ -567,7 +582,7 @@ public void testGetEdgesByLabelAndPropertiesWithRangeCondition() Date expected2 = DateUtil.parse("2016-01-10"); Map properties = ImmutableMap.of( - "date", "P.eq(\"2014-1-10\")"); + "date", "P.eq(\"2014-1-10\")"); List edges = graph().listEdges("created", properties); Date time; @@ -649,19 +664,29 @@ public void testGetEdgesByLabelAndPropertiesWithRangeCondition() @Test public void testGetEdgesByLabelAndPropertiesWithKeepP() - throws ParseException { + throws ParseException { schema().indexLabel("createdByCity").secondary() .onE("created").by("city").create(); schema().indexLabel("createdByDate").secondary() - .onE("created").by("date").create(); + .onE("created").by("date 2&@").create(); BaseClientTest.initEdge(); + { + //test special character + Map properties = ImmutableMap.of( + "date 2&@", "P.eq(\"2014-1-10\")"); + List edges = graph().listEdges("created", properties, false); + Assert.assertEquals(1, edges.size()); + } + + Map properties = ImmutableMap.of( - "date", "P.eq(\"2014-1-10\")"); + "date", "P.eq(\"2014-1-10\")"); List edges = graph().listEdges("created", properties, false); Assert.assertEquals(1, edges.size()); + Assert.assertThrows(ServerException.class, () -> { graph().listEdges("created", properties, true); }, e -> { @@ -779,19 +804,4 @@ public void testQueryByPagingAndFiltering() { e.getMessage()); }); } - - private static void assertContains(List edges, Object source, - String label, Object target, - Object... keyValues) { - Map properties = Utils.asMap(keyValues); - - Edge edge = new Edge(label); - edge.sourceId(source); - edge.targetId(target); - for (String key : properties.keySet()) { - edge.property(key, properties.get(key)); - } - - Assert.assertTrue(Utils.contains(edges, edge)); - } } From 3f8b42da150e131f0de9f3d6d94ebaeef1af0e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Tue, 28 Nov 2023 00:26:50 +0800 Subject: [PATCH 43/53] add encode test case and fix code issue --- .../apache/hugegraph/client/RestClient.java | 3 +- .../apache/hugegraph/driver/HugeClient.java | 2 +- .../hugegraph/exception/ServerException.java | 4 +- .../org/apache/hugegraph/BaseClientTest.java | 8 ++-- .../hugegraph/api/auth/UserApiTest.java | 4 +- .../apache/hugegraph/functional/EdgeTest.java | 41 ++++++++++++++----- 6 files changed, 40 insertions(+), 22 deletions(-) diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java index 508537f3b..a63e1f330 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java @@ -29,7 +29,6 @@ import com.fasterxml.jackson.databind.module.SimpleModule; -import okhttp3.Response; public class RestClient extends AbstractRestClient { @@ -77,7 +76,7 @@ public boolean apiVersionLt(String minVersion) { } @Override - protected void checkStatus(Response response, int... statuses) { + protected void checkStatus(okhttp3.Response response, int... statuses) { boolean match = false; for (int status : statuses) { if (status == response.code()) { diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java index 4eacf15ae..c2ff1ef3a 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java @@ -61,7 +61,7 @@ public HugeClient(HugeClientBuilder builder) { builder.trustStoreFile(), builder.trustStorePassword()); } catch (Exception e) { - log.error("", e); + log.warn("create RestClient instance error", e); throw new ClientException("Failed to connect url '%s'", builder.url()); } try { diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java index d28e451e0..fc3c95ea5 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java @@ -23,8 +23,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import okhttp3.Response; - public class ServerException extends RuntimeException { private static final Logger LOG = LoggerFactory.getLogger(ServerException.class); @@ -44,7 +42,7 @@ public class ServerException extends RuntimeException { private String cause; private Object trace; - public static ServerException fromResponse(Response response) { + public static ServerException fromResponse(okhttp3.Response response) { RestResult rs = new RestResult(response); ServerException exception = new ServerException(rs.content()); exception.status(response.code()); diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java index f2215d49e..80546b84f 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java @@ -175,7 +175,7 @@ protected static void initPropertyKey() { schema.propertyKey("city").asText().ifNotExist().create(); schema.propertyKey("lang").asText().ifNotExist().create(); schema.propertyKey("date").asDate().ifNotExist().create(); - schema.propertyKey("date 2&@").asDate().ifNotExist().create(); + schema.propertyKey("date @&$=*?").asDate().ifNotExist().create(); schema.propertyKey("price").asInt().ifNotExist().create(); schema.propertyKey("weight").asDouble().ifNotExist().create(); } @@ -221,8 +221,8 @@ protected static void initEdgeLabel() { schema.edgeLabel("created") .sourceLabel("person") .targetLabel("software") - .properties("date", "date 2&@", "city") - .nullableKeys("city", "date 2&@") + .properties("date", "date @&$=*?", "city") + .nullableKeys("city", "date @&$=*?") .ifNotExist() .create(); } @@ -285,7 +285,7 @@ protected static void initEdge() { graph().addEdge(markoId, "knows", vadasId, "date", "2012-01-10"); graph().addEdge(markoId, "knows", joshId, "date", "2013-01-10"); graph().addEdge(markoId, "created", lopId, - "date", "2014-01-10", "city", "Shanghai", "date 2&@", "2014-01-10"); + "date", "2014-01-10", "city", "Shanghai"); graph().addEdge(joshId, "created", rippleId, "date", "2015-01-10", "city", "Beijing"); graph().addEdge(joshId, "created", lopId, diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/UserApiTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/UserApiTest.java index f0cfcc27a..826df0898 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/UserApiTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/UserApiTest.java @@ -146,11 +146,11 @@ public void testGet() { public void testGetUserRole() { User user1 = createUser("test1", "psw1"); User user2 = createUser("test2", "psw2"); - User user3 = createUser("test3 aaa", "psw3"); + User user3 = createUser("test3 @&$=*?", "psw3"); Assert.assertEquals("test1", user1.name()); Assert.assertEquals("test2", user2.name()); - Assert.assertContains("test3 aaa", user3.name());//test special character + Assert.assertContains("test3 @&$=*?", user3.name());// test special character UserRole role1 = api.getUserRole(user1.id()); UserRole role2 = api.getUserRole(user2.id()); diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java index cdc6550d0..eb0902597 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java @@ -662,25 +662,46 @@ public void testGetEdgesByLabelAndPropertiesWithRangeCondition() } } + @Test + public void testSpecialCharacter() { + schema().indexLabel("createdByCity").secondary() + .onE("created").by("city").create(); + schema().indexLabel("createdByDate").secondary() + .onE("created").by("date @&$=*?").create(); + + Object markoId = getVertexId("person", "name", "marko"); + Object lopId = getVertexId("software", "name", "lop"); + Object rippleId = getVertexId("software", "name", "ripple"); + graph().addEdge(markoId, "created", lopId, + "date", "2014-01-10", "city", "Shanghai", "date @&$=*?", "2014-01-10"); + graph().addEdge(markoId, "created", rippleId, + "date", "2015-01-10", "city", "Shanghai @&$=*?"); + + Map properties = ImmutableMap.of( + "date @&$=*?", "P.eq(\"2014-1-10\")"); + List edges = graph().listEdges("created", properties, false); + Assert.assertEquals(1, edges.size()); + + Map properties2 = ImmutableMap.of("city", "Shanghai"); + edges = graph().listEdges("created", properties2, true); + Assert.assertEquals(1, edges.size()); + + Map properties3 = ImmutableMap.of("city", "Shanghai @&$=*?"); + edges = graph().listEdges("created", properties3, true); + Assert.assertEquals(1, edges.size()); + + } + @Test public void testGetEdgesByLabelAndPropertiesWithKeepP() throws ParseException { schema().indexLabel("createdByCity").secondary() .onE("created").by("city").create(); schema().indexLabel("createdByDate").secondary() - .onE("created").by("date 2&@").create(); + .onE("created").by("date").create(); BaseClientTest.initEdge(); - { - //test special character - Map properties = ImmutableMap.of( - "date 2&@", "P.eq(\"2014-1-10\")"); - List edges = graph().listEdges("created", properties, false); - Assert.assertEquals(1, edges.size()); - } - - Map properties = ImmutableMap.of( "date", "P.eq(\"2014-1-10\")"); List edges = graph().listEdges("created", properties, false); From 7e2f5ae1d100963ca05a662f646f6b84851cdedd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Tue, 28 Nov 2023 23:07:30 +0800 Subject: [PATCH 44/53] fix test error --- .../src/test/java/org/apache/hugegraph/api/SchemaApiTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/api/SchemaApiTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/api/SchemaApiTest.java index a341e5ece..7e5cf611f 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/api/SchemaApiTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/api/SchemaApiTest.java @@ -39,7 +39,7 @@ public void testList() { Assert.assertTrue(schemas.containsKey("vertexlabels")); Assert.assertTrue(schemas.containsKey("edgelabels")); Assert.assertTrue(schemas.containsKey("indexlabels")); - Assert.assertEquals(7, schemas.get("propertykeys").size()); + Assert.assertEquals(8, schemas.get("propertykeys").size()); Assert.assertEquals(3, schemas.get("vertexlabels").size()); Assert.assertEquals(2, schemas.get("edgelabels").size()); Assert.assertTrue(schemas.get("indexlabels").isEmpty()); From bba55b8a58e39e48d71186395804a476d86b451d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Tue, 28 Nov 2023 23:20:25 +0800 Subject: [PATCH 45/53] fix test error --- .../test/java/org/apache/hugegraph/functional/SchemaTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/functional/SchemaTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/functional/SchemaTest.java index 5407da2aa..7a93f1e82 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/functional/SchemaTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/functional/SchemaTest.java @@ -40,7 +40,7 @@ public void testlist() { Assert.assertTrue(schemas.containsKey("vertexlabels")); Assert.assertTrue(schemas.containsKey("edgelabels")); Assert.assertTrue(schemas.containsKey("indexlabels")); - Assert.assertEquals(7, schemas.get("propertykeys").size()); + Assert.assertEquals(8, schemas.get("propertykeys").size()); Assert.assertEquals(3, schemas.get("vertexlabels").size()); Assert.assertEquals(2, schemas.get("edgelabels").size()); Assert.assertTrue(schemas.get("indexlabels").isEmpty()); From acc65e0d8fce04322e518d8c1c2f517e4e6856b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Wed, 29 Nov 2023 21:58:05 +0800 Subject: [PATCH 46/53] fix code issue --- .../apache/hugegraph/driver/HugeClient.java | 2 +- .../apache/hugegraph/functional/EdgeTest.java | 68 ++++++------------- 2 files changed, 23 insertions(+), 47 deletions(-) diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java index c2ff1ef3a..f0a2dee62 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java @@ -61,7 +61,7 @@ public HugeClient(HugeClientBuilder builder) { builder.trustStoreFile(), builder.trustStorePassword()); } catch (Exception e) { - log.warn("create RestClient instance error", e); + log.warn("Failed to create RestClient instance", e); throw new ClientException("Failed to connect url '%s'", builder.url()); } try { diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java index eb0902597..f379cbf4f 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java @@ -81,8 +81,7 @@ public void testLinkedVertex() { Object peterId = getVertexId("person", "name", "peter"); Object lopId = getVertexId("software", "name", "lop"); - Edge created = graph().addEdge(peterId, "created", lopId, - "date", "2017-03-24"); + Edge created = graph().addEdge(peterId, "created", lopId, "date", "2017-03-24"); Assert.assertTrue(created.linkedVertex(peterId)); Assert.assertTrue(created.linkedVertex(lopId)); } @@ -92,15 +91,12 @@ public void testAddEdgeProperty() { Object peterId = getVertexId("person", "name", "peter"); Object lopId = getVertexId("software", "name", "lop"); - Edge created = graph().addEdge(peterId, "created", lopId, - "date", "2017-03-24"); - Map props = ImmutableMap.of( - "date", Utils.formatDate("2017-03-24")); + Edge created = graph().addEdge(peterId, "created", lopId, "date", "2017-03-24"); + Map props = ImmutableMap.of("date", Utils.formatDate("2017-03-24")); Assert.assertEquals(props, created.properties()); created.property("city", "HongKong"); - props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"), - "city", "HongKong"); + props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"), "city", "HongKong"); Assert.assertEquals(props, created.properties()); } @@ -109,10 +105,8 @@ public void testUpdateEdgeProperty() { Object peterId = getVertexId("person", "name", "peter"); Object lopId = getVertexId("software", "name", "lop"); - Edge created = graph().addEdge(peterId, "created", lopId, - "date", "2017-03-24"); - Map props = ImmutableMap.of( - "date", Utils.formatDate("2017-03-24")); + Edge created = graph().addEdge(peterId, "created", lopId, "date", "2017-03-24"); + Map props = ImmutableMap.of("date", Utils.formatDate("2017-03-24")); Assert.assertEquals(props, created.properties()); created.property("date", "2017-08-08"); @@ -479,8 +473,7 @@ public void testGetEdgesByVertexIdDirectionLabel() { Object lopId = getVertexId("software", "name", "lop"); Object rippleId = getVertexId("software", "name", "ripple"); - List edges = graph().getEdges(joshId, Direction.OUT, - "created"); + List edges = graph().getEdges(joshId, Direction.OUT, "created"); Assert.assertEquals(2, edges.size()); assertContains(edges, joshId, "created", rippleId, "date", Utils.formatDate("2015-01-10"), @@ -501,8 +494,7 @@ public void testGetEdgesByVertexIdDirectionLabelWithLimit1() { Object joshId = getVertexId("person", "name", "josh"); - List edges = graph().getEdges(joshId, Direction.OUT, - "created", 1); + List edges = graph().getEdges(joshId, Direction.OUT, "created", 1); Assert.assertEquals(1, edges.size()); for (Edge edge : edges) { Assert.assertEquals(joshId, edge.sourceId()); @@ -525,11 +517,8 @@ public void testGetEdgesByVertexIdDirectionLabelProperties() { Object joshId = getVertexId("person", "name", "josh"); Object rippleId = getVertexId("software", "name", "ripple"); - Map properties = ImmutableMap.of( - "date", - Utils.formatDate("2015-01-10")); - List edges = graph().getEdges(joshId, Direction.OUT, - "created", properties); + Map properties = ImmutableMap.of("date", Utils.formatDate("2015-01-10")); + List edges = graph().getEdges(joshId, Direction.OUT, "created", properties); Assert.assertEquals(1, edges.size()); assertContains(edges, joshId, "created", rippleId, "date", Utils.formatDate("2015-01-10"), @@ -548,11 +537,8 @@ public void testGetEdgesByVertexIdDirectionLabelPropertiesWithLimit1() { Object joshId = getVertexId("person", "name", "josh"); - Map properties = ImmutableMap.of( - "date", - Utils.formatDate("2015-01-10")); - List edges = graph().getEdges(joshId, Direction.OUT, - "created", properties); + Map properties = ImmutableMap.of("date", Utils.formatDate("2015-01-10")); + List edges = graph().getEdges(joshId, Direction.OUT, "created", properties); Assert.assertEquals(1, edges.size()); for (Edge edge : edges) { Assert.assertEquals(joshId, edge.sourceId()); @@ -581,8 +567,7 @@ public void testGetEdgesByLabelAndPropertiesWithRangeCondition() Date expected = DateUtil.parse("2014-01-10"); Date expected2 = DateUtil.parse("2016-01-10"); - Map properties = ImmutableMap.of( - "date", "P.eq(\"2014-1-10\")"); + Map properties = ImmutableMap.of("date", "P.eq(\"2014-1-10\")"); List edges = graph().listEdges("created", properties); Date time; @@ -628,8 +613,7 @@ public void testGetEdgesByLabelAndPropertiesWithRangeCondition() Assert.assertLte(expected.getTime(), time.getTime()); } - properties = ImmutableMap.of("date", - "P.between(\"2014-1-10\",\"2016-1-10\")"); + properties = ImmutableMap.of("date", "P.between(\"2014-1-10\",\"2016-1-10\")"); edges = graph().listEdges(null, properties); Assert.assertEquals(2, edges.size()); for (Edge e : edges) { @@ -639,8 +623,7 @@ public void testGetEdgesByLabelAndPropertiesWithRangeCondition() Assert.assertLt(expected2.getTime(), time.getTime()); } - properties = ImmutableMap.of("date", - "P.inside(\"2014-1-10\",\"2016-1-10\")"); + properties = ImmutableMap.of("date", "P.inside(\"2014-1-10\",\"2016-1-10\")"); edges = graph().listEdges(null, properties); Assert.assertEquals(1, edges.size()); for (Edge e : edges) { @@ -650,8 +633,7 @@ public void testGetEdgesByLabelAndPropertiesWithRangeCondition() Assert.assertLt(expected2.getTime(), time.getTime()); } - properties = ImmutableMap.of("date", - "P.within(\"2014-1-10\",\"2016-1-10\")"); + properties = ImmutableMap.of("date", "P.within(\"2014-1-10\",\"2016-1-10\")"); edges = graph().listEdges(null, properties); Assert.assertEquals(2, edges.size()); for (Edge e : edges) { @@ -663,7 +645,7 @@ public void testGetEdgesByLabelAndPropertiesWithRangeCondition() } @Test - public void testSpecialCharacter() { + public void testGetEdgesWithSpecialChars() { schema().indexLabel("createdByCity").secondary() .onE("created").by("city").create(); schema().indexLabel("createdByDate").secondary() @@ -677,8 +659,7 @@ public void testSpecialCharacter() { graph().addEdge(markoId, "created", rippleId, "date", "2015-01-10", "city", "Shanghai @&$=*?"); - Map properties = ImmutableMap.of( - "date @&$=*?", "P.eq(\"2014-1-10\")"); + Map properties = ImmutableMap.of("date @&$=*?", "P.eq(\"2014-1-10\")"); List edges = graph().listEdges("created", properties, false); Assert.assertEquals(1, edges.size()); @@ -689,7 +670,6 @@ public void testSpecialCharacter() { Map properties3 = ImmutableMap.of("city", "Shanghai @&$=*?"); edges = graph().listEdges("created", properties3, true); Assert.assertEquals(1, edges.size()); - } @Test @@ -702,8 +682,7 @@ public void testGetEdgesByLabelAndPropertiesWithKeepP() BaseClientTest.initEdge(); - Map properties = ImmutableMap.of( - "date", "P.eq(\"2014-1-10\")"); + Map properties = ImmutableMap.of("date", "P.eq(\"2014-1-10\")"); List edges = graph().listEdges("created", properties, false); Assert.assertEquals(1, edges.size()); @@ -751,10 +730,8 @@ public void testIterateEdgesByVertexId() { edges = graph().iterateEdges(markoId, Direction.OUT, "created", 1); Assert.assertEquals(1, Iterators.size(edges)); - Map properties = ImmutableMap.of("date", - "P.gt(\"2012-1-1\")"); - Iterator iter = graph().iterateEdges(markoId, Direction.OUT, - "knows", properties, 1); + Map properties = ImmutableMap.of("date", "P.gt(\"2012-1-1\")"); + Iterator iter = graph().iterateEdges(markoId, Direction.OUT, "knows", properties, 1); Assert.assertEquals(2, Iterators.size(iter)); } @@ -821,8 +798,7 @@ public void testQueryByPagingAndFiltering() { .binding("vid", v1.id()) .execute(); }, e -> { - Assert.assertContains("Can't query by paging and filtering", - e.getMessage()); + Assert.assertContains("Can't query by paging and filtering", e.getMessage()); }); } } From bb79524a7f3a1603c5ee3176a1901afda53d3ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Wed, 29 Nov 2023 21:59:00 +0800 Subject: [PATCH 47/53] fix code issue --- .../main/java/org/apache/hugegraph/driver/HugeClient.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java index f0a2dee62..97794fc51 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java @@ -23,12 +23,13 @@ import org.apache.hugegraph.rest.ClientException; import org.apache.hugegraph.util.VersionUtil; import org.apache.hugegraph.version.ClientVersion; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import lombok.extern.slf4j.Slf4j; - -@Slf4j public class HugeClient implements Closeable { + private static final Logger LOG = LoggerFactory.getLogger(RestClient.class); + static { ClientVersion.check(); } From 4441ac87666647dd154ac516549fa0ba1b3c168c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Wed, 29 Nov 2023 22:00:37 +0800 Subject: [PATCH 48/53] fix code issue --- .../src/main/java/org/apache/hugegraph/driver/HugeClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java index 97794fc51..0f457c0d9 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java @@ -62,7 +62,7 @@ public HugeClient(HugeClientBuilder builder) { builder.trustStoreFile(), builder.trustStorePassword()); } catch (Exception e) { - log.warn("Failed to create RestClient instance", e); + LOG.warn("Failed to create RestClient instance", e); throw new ClientException("Failed to connect url '%s'", builder.url()); } try { From 0d215a49a9e07e4349e35b957221b54d61b7aa0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Wed, 29 Nov 2023 23:21:50 +0800 Subject: [PATCH 49/53] update hg server commitId --- .github/workflows/client-ci.yml | 4 ++-- .github/workflows/hubble-ci.yml | 2 +- .github/workflows/loader-ci.yml | 2 +- .github/workflows/tools-ci.yml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/client-ci.yml b/.github/workflows/client-ci.yml index d0943fe41..701437278 100644 --- a/.github/workflows/client-ci.yml +++ b/.github/workflows/client-ci.yml @@ -24,11 +24,11 @@ jobs: env: USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-client/assembly/travis - COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314 + COMMIT_ID: 69e6b461add1051831dd6cc0c36a5e249a3b3176 strategy: fail-fast: false matrix: - JAVA_VERSION: ['8'] + JAVA_VERSION: [ '8' ] steps: - name: Install JDK 8 uses: actions/setup-java@v3 diff --git a/.github/workflows/hubble-ci.yml b/.github/workflows/hubble-ci.yml index 754db23af..8b7da0f9d 100644 --- a/.github/workflows/hubble-ci.yml +++ b/.github/workflows/hubble-ci.yml @@ -24,7 +24,7 @@ on: env: TRAVIS_DIR: hugegraph-hubble/hubble-dist/assembly/travis # TODO: need update it later (eed6103359fe40d2f1476fb8c56d9388c3111a99) - COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314 + COMMIT_ID: 69e6b461add1051831dd6cc0c36a5e249a3b3176 jobs: hubble-ci: diff --git a/.github/workflows/loader-ci.yml b/.github/workflows/loader-ci.yml index a3752e248..8e76d1cf6 100644 --- a/.github/workflows/loader-ci.yml +++ b/.github/workflows/loader-ci.yml @@ -26,7 +26,7 @@ jobs: USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-loader/assembly/travis STATIC_DIR: hugegraph-loader/assembly/static - COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314 + COMMIT_ID: 69e6b461add1051831dd6cc0c36a5e249a3b3176 DB_USER: root DB_PASS: root DB_DATABASE: load_test diff --git a/.github/workflows/tools-ci.yml b/.github/workflows/tools-ci.yml index 8db02af7c..6f52a8a0d 100644 --- a/.github/workflows/tools-ci.yml +++ b/.github/workflows/tools-ci.yml @@ -25,7 +25,7 @@ jobs: USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-tools/assembly/travis # TODO: could we use one param to unify it? or use a action template (could use one ci file) - COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314 + COMMIT_ID: 69e6b461add1051831dd6cc0c36a5e249a3b3176 steps: - name: Install JDK 11 uses: actions/setup-java@v3 From e65644be44e010f1ede77dc74c8306802ad5fe08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=AE=87?= <940643974@qq.com> Date: Thu, 30 Nov 2023 23:10:22 +0800 Subject: [PATCH 50/53] debug ci error --- .../assembly/travis/install-hugegraph-from-source.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hugegraph-client/assembly/travis/install-hugegraph-from-source.sh b/hugegraph-client/assembly/travis/install-hugegraph-from-source.sh index fe9024077..13d5da494 100755 --- a/hugegraph-client/assembly/travis/install-hugegraph-from-source.sh +++ b/hugegraph-client/assembly/travis/install-hugegraph-from-source.sh @@ -60,5 +60,5 @@ echo "gremlinserver.url=http://127.0.0.1:8282" >> ${REST_SERVER_CONFIG} # start HugeGraphServer with https protocol bin/init-store.sh -bin/start-hugegraph.sh +bin/start-hugegraph.sh || (cat logs/hugegraph-server.log && exit 1) cd ../ From 142192a73aba87580e4cf5ab90dcad38f3ced41e Mon Sep 17 00:00:00 2001 From: imbajin Date: Mon, 4 Dec 2023 16:13:27 +0800 Subject: [PATCH 51/53] revert commit ID & let it pass 100 --- .github/workflows/client-ci.yml | 6 +++-- .github/workflows/hubble-ci.yml | 7 +++--- .github/workflows/loader-ci.yml | 6 +++-- .github/workflows/tools-ci.yml | 5 +++-- .../travis/install-hugegraph-from-source.sh | 2 +- .../assembly/travis/download-hugegraph.sh | 22 +++++++++---------- .../travis/install-hugegraph-from-source.sh | 2 +- .../travis/install-hugegraph-from-source.sh | 2 +- 8 files changed, 29 insertions(+), 23 deletions(-) diff --git a/.github/workflows/client-ci.yml b/.github/workflows/client-ci.yml index 701437278..e8bda9e87 100644 --- a/.github/workflows/client-ci.yml +++ b/.github/workflows/client-ci.yml @@ -24,7 +24,8 @@ jobs: env: USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-client/assembly/travis - COMMIT_ID: 69e6b461add1051831dd6cc0c36a5e249a3b3176 + # TODO: replace it with the (latest - n) commit id (n >= 15) + COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314 strategy: fail-fast: false matrix: @@ -70,6 +71,7 @@ jobs: mvn test -Dtest=FuncTestSuite - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3.0.0 + uses: codecov/codecov-action@v with: + token: ${{ secrets.CODECOV_TOKEN }} file: target/jacoco.xml diff --git a/.github/workflows/hubble-ci.yml b/.github/workflows/hubble-ci.yml index 8b7da0f9d..ea186d40a 100644 --- a/.github/workflows/hubble-ci.yml +++ b/.github/workflows/hubble-ci.yml @@ -23,8 +23,8 @@ on: env: TRAVIS_DIR: hugegraph-hubble/hubble-dist/assembly/travis - # TODO: need update it later (eed6103359fe40d2f1476fb8c56d9388c3111a99) - COMMIT_ID: 69e6b461add1051831dd6cc0c36a5e249a3b3176 + # TODO: replace it with the (latest - n) commit id (n >= 15) + COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314 jobs: hubble-ci: @@ -114,6 +114,7 @@ jobs: hubble-dist/assembly/travis/run-api-test.sh - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3.0.0 + uses: codecov/codecov-action@v3 with: + token: ${{ secrets.CODECOV_TOKEN }} file: target/site/jacoco/*.xml diff --git a/.github/workflows/loader-ci.yml b/.github/workflows/loader-ci.yml index 8e76d1cf6..3c676302b 100644 --- a/.github/workflows/loader-ci.yml +++ b/.github/workflows/loader-ci.yml @@ -26,7 +26,8 @@ jobs: USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-loader/assembly/travis STATIC_DIR: hugegraph-loader/assembly/static - COMMIT_ID: 69e6b461add1051831dd6cc0c36a5e249a3b3176 + # TODO: replace it with the (latest - n) commit id (n >= 15) + COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314 DB_USER: root DB_PASS: root DB_DATABASE: load_test @@ -75,6 +76,7 @@ jobs: mvn test -P kafka - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3.0.0 + uses: codecov/codecov-action@v3 with: + token: ${{ secrets.CODECOV_TOKEN }} file: target/jacoco.xml diff --git a/.github/workflows/tools-ci.yml b/.github/workflows/tools-ci.yml index 6f52a8a0d..f00582b2e 100644 --- a/.github/workflows/tools-ci.yml +++ b/.github/workflows/tools-ci.yml @@ -25,7 +25,7 @@ jobs: USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-tools/assembly/travis # TODO: could we use one param to unify it? or use a action template (could use one ci file) - COMMIT_ID: 69e6b461add1051831dd6cc0c36a5e249a3b3176 + COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314 steps: - name: Install JDK 11 uses: actions/setup-java@v3 @@ -57,6 +57,7 @@ jobs: run: | mvn test -Dtest=FuncTestSuite -pl hugegraph-tools -ntp - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3.0.0 + uses: codecov/codecov-action@v3 with: + token: ${{ secrets.CODECOV_TOKEN }} file: target/jacoco.xml diff --git a/hugegraph-client/assembly/travis/install-hugegraph-from-source.sh b/hugegraph-client/assembly/travis/install-hugegraph-from-source.sh index 13d5da494..2c9ea319e 100755 --- a/hugegraph-client/assembly/travis/install-hugegraph-from-source.sh +++ b/hugegraph-client/assembly/travis/install-hugegraph-from-source.sh @@ -26,7 +26,7 @@ HUGEGRAPH_GIT_URL="https://github.com/apache/hugegraph.git" GIT_DIR=hugegraph # download code and compile -git clone --depth 100 ${HUGEGRAPH_GIT_URL} $GIT_DIR +git clone --depth 150 ${HUGEGRAPH_GIT_URL} $GIT_DIR cd "${GIT_DIR}" git checkout "${COMMIT_ID}" mvn package -DskipTests -Dmaven.javadoc.skip=true -ntp diff --git a/hugegraph-hubble/hubble-dist/assembly/travis/download-hugegraph.sh b/hugegraph-hubble/hubble-dist/assembly/travis/download-hugegraph.sh index 7813cc3ba..1a08376dd 100755 --- a/hugegraph-hubble/hubble-dist/assembly/travis/download-hugegraph.sh +++ b/hugegraph-hubble/hubble-dist/assembly/travis/download-hugegraph.sh @@ -1,19 +1,19 @@ #!/bin/bash # # 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 +# 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 +# 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. +# 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. # set -ev @@ -26,7 +26,7 @@ HUGEGRAPH_GIT_URL="https://github.com/apache/hugegraph.git" GIT_DIR=hugegraph # download code and compile -git clone --depth 100 $HUGEGRAPH_GIT_URL $GIT_DIR +git clone --depth 150 $HUGEGRAPH_GIT_URL $GIT_DIR cd "${GIT_DIR}" git checkout "${COMMIT_ID}" mvn package -DskipTests -Dmaven.javadoc.skip=true -ntp diff --git a/hugegraph-loader/assembly/travis/install-hugegraph-from-source.sh b/hugegraph-loader/assembly/travis/install-hugegraph-from-source.sh index 60adcfacd..202f45691 100755 --- a/hugegraph-loader/assembly/travis/install-hugegraph-from-source.sh +++ b/hugegraph-loader/assembly/travis/install-hugegraph-from-source.sh @@ -24,7 +24,7 @@ fi COMMIT_ID=$1 HUGEGRAPH_GIT_URL="https://github.com/apache/hugegraph.git" -git clone --depth 100 ${HUGEGRAPH_GIT_URL} hugegraph +git clone --depth 150 ${HUGEGRAPH_GIT_URL} hugegraph cd hugegraph git checkout "${COMMIT_ID}" mvn package -DskipTests -Dmaven.javadoc.skip=true -ntp diff --git a/hugegraph-tools/assembly/travis/install-hugegraph-from-source.sh b/hugegraph-tools/assembly/travis/install-hugegraph-from-source.sh index 5b3b2637c..45de8924c 100755 --- a/hugegraph-tools/assembly/travis/install-hugegraph-from-source.sh +++ b/hugegraph-tools/assembly/travis/install-hugegraph-from-source.sh @@ -25,7 +25,7 @@ HUGEGRAPH_GIT_URL="https://github.com/apache/hugegraph.git" GIT_DIR=hugegraph # download code and compile -git clone --depth 100 $HUGEGRAPH_GIT_URL $GIT_DIR +git clone --depth 150 $HUGEGRAPH_GIT_URL $GIT_DIR cd "${GIT_DIR}" git checkout "${COMMIT_ID}" mvn package -DskipTests -Dmaven.javadoc.skip=true -ntp From a18802b2bb7e50c2804c54106dd5d521e1be21a8 Mon Sep 17 00:00:00 2001 From: imbajin Date: Mon, 4 Dec 2023 16:18:27 +0800 Subject: [PATCH 52/53] Update client-ci.yml --- .github/workflows/client-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/client-ci.yml b/.github/workflows/client-ci.yml index e8bda9e87..b8c19c706 100644 --- a/.github/workflows/client-ci.yml +++ b/.github/workflows/client-ci.yml @@ -71,7 +71,7 @@ jobs: mvn test -Dtest=FuncTestSuite - name: Upload coverage to Codecov - uses: codecov/codecov-action@v + uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} file: target/jacoco.xml From a3b4423e0bcf876cf4d85cdd7379502e904c49a3 Mon Sep 17 00:00:00 2001 From: imbajin Date: Tue, 5 Dec 2023 14:34:56 +0800 Subject: [PATCH 53/53] tiny fix --- .../hugegraph/api/graphs/GraphsAPI.java | 14 +++++------- .../apache/hugegraph/driver/HugeClient.java | 2 +- .../hugegraph/exception/ServerException.java | 6 ++--- .../org/apache/hugegraph/BaseClientTest.java | 22 ++++++------------- .../apache/hugegraph/functional/EdgeTest.java | 5 ++--- 5 files changed, 18 insertions(+), 31 deletions(-) diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java index 3a85c3d82..8310e44f1 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java @@ -51,8 +51,7 @@ protected String type() { } @SuppressWarnings("unchecked") - public Map create(String name, String cloneGraphName, - String configText) { + public Map create(String name, String cloneGraphName, String configText) { this.client.checkApiVersion("0.67", "dynamic graph add"); RestHeaders headers = new RestHeaders().add(RestHeaders.CONTENT_TYPE, "text/plain"); Map params = null; @@ -87,8 +86,8 @@ public void drop(String graph, String message) { } public void mode(String graph, GraphMode mode) { - // NOTE: Must provide id for PUT. If use "graph/mode", "/" will - // be encoded to "%2F". So use "mode" here although inaccurate. + // NOTE: Must provide id for PUT. If you use "graph/mode", "/" will + // be encoded to "%2F". So use "mode" here, although inaccurate. this.client.put(joinPath(this.path(), graph, MODE), null, mode); } @@ -109,16 +108,15 @@ public GraphMode mode(String graph) { public void readMode(String graph, GraphReadMode readMode) { this.client.checkApiVersion("0.59", "graph read mode"); - // NOTE: Must provide id for PUT. If use "graph/graph_read_mode", "/" - // will be encoded to "%2F". So use "graph_read_mode" here although + // NOTE: Must provide id for PUT. If you use "graph/graph_read_mode", "/" + // will be encoded to "%2F". So use "graph_read_mode" here, although // inaccurate. this.client.put(joinPath(this.path(), graph, GRAPH_READ_MODE), null, readMode); } public GraphReadMode readMode(String graph) { this.client.checkApiVersion("0.59", "graph read mode"); - RestResult result = this.client.get(joinPath(this.path(), graph), - GRAPH_READ_MODE); + RestResult result = this.client.get(joinPath(this.path(), graph), GRAPH_READ_MODE); @SuppressWarnings("unchecked") Map readMode = result.readObject(Map.class); String value = readMode.get(GRAPH_READ_MODE); diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java index 6b24407d5..56acc3376 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java @@ -112,7 +112,7 @@ private void initManagers(RestClient client, String graph) { private void checkServerApiVersion() { VersionUtil.Version apiVersion = VersionUtil.Version.of(this.version.getApiVersion()); // TODO: find a way to keep the range of api version correct automatically - // 0.81 equals to the {latest_api_version} +10 + // 0.81 equals to the {latest_api_version} +10 VersionUtil.check(apiVersion, "0.38", "0.81", "hugegraph-api in server"); this.client.apiVersion(apiVersion); } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java index fc3c95ea5..aa9826320 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java @@ -29,13 +29,11 @@ public class ServerException extends RuntimeException { private static final long serialVersionUID = 6335623004322652358L; - private static final String[] EXCEPTION_KEYS = {"exception", - "Exception-Class"}; + private static final String[] EXCEPTION_KEYS = {"exception", "Exception-Class"}; private static final String[] MESSAGE_KEYS = {"message"}; private static final String[] CAUSE_KEYS = {"cause", "exceptions"}; private static final String[] TRACE_KEYS = {"trace", "stackTrace"}; - private int status = 0; private String exception; private String message; @@ -54,7 +52,7 @@ public static ServerException fromResponse(okhttp3.Response response) { exception.cause = (String) getByKeys(json, CAUSE_KEYS); exception.trace = getByKeys(json, TRACE_KEYS); } catch (Exception ignored) { - LOG.error("ServerException fromResponse excepiton"); + LOG.error("ServerException fromResponse exception"); } return exception; diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java index 80546b84f..471f135de 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java @@ -57,11 +57,8 @@ public class BaseClientTest { private static HugeClient client; - protected static HugeClient open() { - client = HugeClient.builder(BASE_URL, GRAPH) - .configUser(USERNAME, PASSWORD) - .build(); - return client; + protected static void open() { + client = HugeClient.builder(BASE_URL, GRAPH).configUser(USERNAME, PASSWORD).build(); } @BeforeClass @@ -125,8 +122,7 @@ public static MetricsManager metrics() { return client.metrics(); } - protected static Object getVertexId(String label, String key, - String value) { + protected static Object getVertexId(String label, String key, String value) { return getVertex(label, key, value).id(); } @@ -148,23 +144,19 @@ protected static Edge getEdge(String label, String key, String value) { return edges.get(0); } - protected static void assertContains(List propertyKeys, - PropertyKey propertyKey) { + protected static void assertContains(List propertyKeys, PropertyKey propertyKey) { Assert.assertTrue(Utils.contains(propertyKeys, propertyKey)); } - protected static void assertContains(List vertexLabels, - VertexLabel vertexLabel) { + protected static void assertContains(List vertexLabels, VertexLabel vertexLabel) { Assert.assertTrue(Utils.contains(vertexLabels, vertexLabel)); } - protected static void assertContains(List edgeLabels, - EdgeLabel edgeLabel) { + protected static void assertContains(List edgeLabels, EdgeLabel edgeLabel) { Assert.assertTrue(Utils.contains(edgeLabels, edgeLabel)); } - protected static void assertContains(List indexLabels, - IndexLabel indexLabel) { + protected static void assertContains(List indexLabels, IndexLabel indexLabel) { Assert.assertTrue(Utils.contains(indexLabels, indexLabel)); } diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java index f379cbf4f..eafb2fe1e 100644 --- a/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java +++ b/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java @@ -46,9 +46,8 @@ public class EdgeTest extends BaseFuncTest { - private static void assertContains(List edges, Object source, - String label, Object target, - Object... keyValues) { + private static void assertContains(List edges, Object source, String label, + Object target, Object... keyValues) { Map properties = Utils.asMap(keyValues); Edge edge = new Edge(label);