Copilot commented on code in PR #2899:
URL:
https://github.com/apache/incubator-hugegraph/pull/2899#discussion_r2490009784
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/AccessAPI.java:
##########
@@ -64,15 +63,13 @@ public class AccessAPI extends API {
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String create(@Context GraphManager manager,
@PathParam("graphspace") String graphSpace,
- @PathParam("graph") String graph,
JsonAccess jsonAccess) {
- LOG.debug("Graph [{}] create access: {}", graph, jsonAccess);
+ LOG.debug("GraphSpace [{}] create access: {}", graphSpace, jsonAccess);
Review Comment:
Default toString(): JsonAccess inherits toString() from Object, and so is
not suitable for printing.
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/AccessAPI.java:
##########
@@ -82,13 +79,11 @@ public String create(@Context GraphManager manager,
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String update(@Context GraphManager manager,
@PathParam("graphspace") String graphSpace,
- @PathParam("graph") String graph,
@PathParam("id") String id,
JsonAccess jsonAccess) {
- LOG.debug("Graph [{}] update access: {}", graph, jsonAccess);
+ LOG.debug("GraphSpace [{}] update access: {}", graphSpace, jsonAccess);
Review Comment:
Default toString(): JsonAccess inherits toString() from Object, and so is
not suitable for printing.
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/BelongAPI.java:
##########
@@ -81,13 +78,11 @@ public String create(@Context GraphManager manager,
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String update(@Context GraphManager manager,
@PathParam("graphspace") String graphSpace,
- @PathParam("graph") String graph,
@PathParam("id") String id,
JsonBelong jsonBelong) {
- LOG.debug("Graph [{}] update belong: {}", graph, jsonBelong);
+ LOG.debug("GraphSpace [{}] update belong: {}", graphSpace, jsonBelong);
Review Comment:
Default toString(): JsonBelong inherits toString() from Object, and so is
not suitable for printing.
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/GroupAPI.java:
##########
@@ -61,33 +61,29 @@ public class GroupAPI extends API {
@Status(Status.CREATED)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
+ @RolesAllowed({"admin"})
public String create(@Context GraphManager manager,
- @PathParam("graphspace") String graphSpace,
- @PathParam("graph") String graph,
JsonGroup jsonGroup) {
- LOG.debug("Graph [{}] create group: {}", graph, jsonGroup);
+ LOG.debug("create group: {}", jsonGroup);
checkCreatingBody(jsonGroup);
- HugeGraph g = graph(manager, graphSpace, graph);
HugeGroup group = jsonGroup.build();
group.id(manager.authManager().createGroup(group));
- return manager.serializer(g).writeAuthElement(group);
+ return manager.serializer().writeAuthElement(group);
}
@PUT
@Timed
@Path("{id}")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
+ @RolesAllowed({"admin"})
public String update(@Context GraphManager manager,
- @PathParam("graphspace") String graphSpace,
- @PathParam("graph") String graph,
@PathParam("id") String id,
JsonGroup jsonGroup) {
- LOG.debug("Graph [{}] update group: {}", graph, jsonGroup);
+ LOG.debug("update group: {}", jsonGroup);
Review Comment:
Default toString(): JsonGroup inherits toString() from Object, and so is not
suitable for printing.
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java:
##########
@@ -66,15 +65,13 @@ public class UserAPI extends API {
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String create(@Context GraphManager manager,
@PathParam("graphspace") String graphSpace,
- @PathParam("graph") String graph,
JsonUser jsonUser) {
- LOG.debug("Graph [{}] create user: {}", graph, jsonUser);
+ LOG.debug("GraphSpace [{}] create user: {}", graphSpace, jsonUser);
Review Comment:
Default toString(): JsonUser inherits toString() from Object, and so is not
suitable for printing.
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java:
##########
@@ -84,13 +81,11 @@ public String create(@Context GraphManager manager,
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String update(@Context GraphManager manager,
@PathParam("graphspace") String graphSpace,
- @PathParam("graph") String graph,
@PathParam("id") String id,
JsonUser jsonUser) {
- LOG.debug("Graph [{}] update user: {}", graph, jsonUser);
+ LOG.debug("GraphSpace [{}] update user: {}", graphSpace, jsonUser);
Review Comment:
Default toString(): JsonUser inherits toString() from Object, and so is not
suitable for printing.
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/BelongAPI.java:
##########
@@ -63,15 +62,13 @@ public class BelongAPI extends API {
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String create(@Context GraphManager manager,
@PathParam("graphspace") String graphSpace,
- @PathParam("graph") String graph,
JsonBelong jsonBelong) {
- LOG.debug("Graph [{}] create belong: {}", graph, jsonBelong);
+ LOG.debug("GraphSpace [{}] create belong: {}", graphSpace, jsonBelong);
Review Comment:
Default toString(): JsonBelong inherits toString() from Object, and so is
not suitable for printing.
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/TargetAPI.java:
##########
@@ -185,6 +173,17 @@ public HugeTarget build() {
return target;
}
+ @Override
+ public String toString() {
+ return "JsonTarget{" +
+ "name='" + name + '\'' +
+ ", graph='" + graph + '\'' +
+ ", url='" + url + '\'' +
+ ", resources=" + resources +
+ '}';
+ }
+
+
Review Comment:
[nitpick] Extra blank line should be removed to maintain consistent code
formatting.
```suggestion
```
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/GroupAPI.java:
##########
@@ -61,33 +61,29 @@ public class GroupAPI extends API {
@Status(Status.CREATED)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
+ @RolesAllowed({"admin"})
public String create(@Context GraphManager manager,
- @PathParam("graphspace") String graphSpace,
- @PathParam("graph") String graph,
JsonGroup jsonGroup) {
- LOG.debug("Graph [{}] create group: {}", graph, jsonGroup);
+ LOG.debug("create group: {}", jsonGroup);
Review Comment:
Default toString(): JsonGroup inherits toString() from Object, and so is not
suitable for printing.
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/ManagerAPI.java:
##########
@@ -0,0 +1,279 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * 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.api.auth;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hugegraph.api.API;
+import org.apache.hugegraph.api.filter.StatusFilter;
+import org.apache.hugegraph.auth.AuthManager;
+import org.apache.hugegraph.auth.HugeGraphAuthProxy;
+import org.apache.hugegraph.auth.HugePermission;
+import org.apache.hugegraph.core.GraphManager;
+import org.apache.hugegraph.define.Checkable;
+import org.apache.hugegraph.util.E;
+import org.apache.hugegraph.util.Log;
+import org.slf4j.Logger;
+
+import com.codahale.metrics.annotation.Timed;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.ImmutableMap;
+
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.inject.Singleton;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.DELETE;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.core.Context;
+
+@Path("graphspaces/{graphspace}/auth/managers")
+@Singleton
+@Tag(name = "ManagerAPI")
+public class ManagerAPI extends API {
+
+ private static final Logger LOG = Log.logger(ManagerAPI.class);
+
+ @POST
+ @Timed
+ @StatusFilter.Status(StatusFilter.Status.CREATED)
+ @Consumes(APPLICATION_JSON)
+ @Produces(APPLICATION_JSON_WITH_CHARSET)
+ public String createManager(@Context GraphManager manager,
+ @PathParam("graphspace") String graphSpace,
+ JsonManager jsonManager) {
+ LOG.debug("Create manager: {}", jsonManager);
Review Comment:
Default toString(): JsonManager inherits toString() from Object, and so is
not suitable for printing.
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/LoginAPI.java:
##########
@@ -65,17 +63,14 @@ public class LoginAPI extends API {
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String login(@Context GraphManager manager,
- @PathParam("graphspace") String graphSpace,
- @PathParam("graph") String graph,
JsonLogin jsonLogin) {
- LOG.debug("Graph [{}] user login: {}", graph, jsonLogin);
+ LOG.debug("user login: {}", jsonLogin);
Review Comment:
Default toString(): JsonLogin inherits toString() from Object, and so is not
suitable for printing.
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/ProjectAPI.java:
##########
@@ -70,20 +69,18 @@ public class ProjectAPI extends API {
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String create(@Context GraphManager manager,
@PathParam("graphspace") String graphSpace,
- @PathParam("graph") String graph,
JsonProject jsonProject) {
- LOG.debug("Graph [{}] create project: {}", graph, jsonProject);
+ LOG.debug("GraphSpace [{}] create project: {}", graphSpace,
jsonProject);
Review Comment:
Default toString(): JsonProject inherits toString() from Object, and so is
not suitable for printing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]