Skip to content

Commit

Permalink
use hg-common-1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostyHec committed Oct 13, 2024
1 parent 5c79ea4 commit deadd30
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 79 deletions.
5 changes: 3 additions & 2 deletions hugegraph-hubble/hubble-be/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
<!-- TODO X FIX HERE-->
<groupId>org.apache.hugegraph</groupId>
<artifactId>hugegraph-common</artifactId>
<!-- <version>1.3.0</version>-->
<version>1.0.01</version>
<version>1.3.0</version>
<!-- <version>1.0.01</version>-->
<exclusions>
<exclusion>
<groupId>com.baidu.hugegraph</groupId>
Expand Down Expand Up @@ -212,6 +212,7 @@
<!-- TODO X FIX HERE-->
<groupId>org.apache.hugegraph</groupId>
<artifactId>hugegraph-client</artifactId>
<!-- <version>1.5.0</version>-->
<version>4.0.0-SNAPSHOT</version>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,76 +16,76 @@
* under the License.
*/

package org.apache.hugegraph.controller.op;

import lombok.SneakyThrows;
import org.apache.hugegraph.common.Constant;
import org.apache.hugegraph.controller.BaseController;
import org.apache.hugegraph.entity.op.AuditEntity;
import org.apache.hugegraph.exception.InternalException;
import org.apache.hugegraph.logger.AuditOperationEnum;
import org.apache.hugegraph.service.op.AuditService;
import org.apache.hugegraph.util.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping(Constant.API_VERSION + "audits")
public class AuditController extends BaseController {
@Autowired
AuditService auditService;

@GetMapping("operations/list")
public Object listOperations() {
List<String> operations = Arrays.stream(AuditOperationEnum.values())
.map(AuditOperationEnum::getName)
.collect(Collectors.toList());

return operations;
}

@GetMapping("services/list")
public Object listServices() throws IOException {
List<String> operations = auditService.listServices();

return operations;
}

@SneakyThrows
@PostMapping("query")
public Object query(@RequestBody AuditService.AuditReq auditReq) {
return auditService.queryPage(auditReq);
}

@PostMapping("export")
public void export(HttpServletResponse response,
@RequestBody AuditService.AuditReq auditReq) {
String fileName = String.format("audit.txt", auditReq.startDatetime,
auditReq.endDatetime);

response.setCharacterEncoding("UTF-8");
response.setContentType("application/octet-stream");
response.setHeader("Access-Control-Expose-Headers",
"Content-Disposition");
response.setHeader("Content-Disposition",
"attachment;filename=" + fileName);
try {
OutputStream os = response.getOutputStream();
for (AuditEntity auditEntity : auditService.export(auditReq)) {
os.write((JsonUtil.toJson(auditEntity) + "\n")
.getBytes(StandardCharsets.UTF_8));
}
os.close();
} catch (IOException e) {
throw new InternalException("Audit Log Write Error", e);
}
}
}
//package org.apache.hugegraph.controller.op;
// TODO RECOVER WHEN EVALUATED
//import lombok.SneakyThrows;
//import org.apache.hugegraph.common.Constant;
//import org.apache.hugegraph.controller.BaseController;
//import org.apache.hugegraph.entity.op.AuditEntity;
//import org.apache.hugegraph.exception.InternalException;
//import org.apache.hugegraph.logger.AuditOperationEnum;
//import org.apache.hugegraph.service.op.AuditService;
//import org.apache.hugegraph.util.JsonUtil;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.io.OutputStream;
//import java.nio.charset.StandardCharsets;
//import java.util.Arrays;
//import java.util.List;
//import java.util.stream.Collectors;
//
//@RestController
//@RequestMapping(Constant.API_VERSION + "audits")
//public class AuditController extends BaseController {
// @Autowired
// AuditService auditService;
//
// @GetMapping("operations/list")
// public Object listOperations() {
// List<String> operations = Arrays.stream(AuditOperationEnum.values())
// .map(AuditOperationEnum::getName)
// .collect(Collectors.toList());
//
// return operations;
// }
//
// @GetMapping("services/list")
// public Object listServices() throws IOException {
// List<String> operations = auditService.listServices();
//
// return operations;
// }
//
// @SneakyThrows
// @PostMapping("query")
// public Object query(@RequestBody AuditService.AuditReq auditReq) {
// return auditService.queryPage(auditReq);
// }
//
// @PostMapping("export")
// public void export(HttpServletResponse response,
// @RequestBody AuditService.AuditReq auditReq) {
// String fileName = String.format("audit.txt", auditReq.startDatetime,
// auditReq.endDatetime);
//
// response.setCharacterEncoding("UTF-8");
// response.setContentType("application/octet-stream");
// response.setHeader("Access-Control-Expose-Headers",
// "Content-Disposition");
// response.setHeader("Content-Disposition",
// "attachment;filename=" + fileName);
// try {
// OutputStream os = response.getOutputStream();
// for (AuditEntity auditEntity : auditService.export(auditReq)) {
// os.write((JsonUtil.toJson(auditEntity) + "\n")
// .getBytes(StandardCharsets.UTF_8));
// }
// os.close();
// } catch (IOException e) {
// throw new InternalException("Audit Log Write Error", e);
// }
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

package org.apache.hugegraph.service.saas;

import jakarta.ws.rs.core.Response;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Response;
import org.apache.hugegraph.config.HugeConfig;
import org.apache.hugegraph.options.HubbleOptions;
import org.apache.hugegraph.rest.AbstractRestClient;
Expand Down Expand Up @@ -161,16 +161,26 @@ private static String encodeUrl(String url) {
.replaceAll("%29", ")")
.replaceAll("\\+", "%20");
}
// TODO re-evaluate this change
// private static class MetricsClient extends AbstractRestClient {
// public MetricsClient(String url, int timeout) {
// super(url, timeout);
// }
//
// @Override
// protected void checkStatus(Response response, Response.Status... statuses) {
//
// }
//
// }

private static class MetricsClient extends AbstractRestClient {
public MetricsClient(String url, int timeout) {
super(url, timeout);
}

@Override
protected void checkStatus(Response response, Response.Status... statuses) {
protected void checkStatus(Response response, int... ints) {

}

}
}

0 comments on commit deadd30

Please sign in to comment.