use of com.baidu.hugegraph.exception.ExternalException in project incubator-hugegraph-toolchain by apache.
the class GremlinQueryService method getRealVertexId.
private Object getRealVertexId(int connId, AdjacentQuery query) {
VertexLabelEntity entity = this.vlService.get(query.getVertexLabel(), connId);
IdStrategy idStrategy = entity.getIdStrategy();
String rawVertexId = query.getVertexId();
try {
if (idStrategy == IdStrategy.AUTOMATIC || idStrategy == IdStrategy.CUSTOMIZE_NUMBER) {
return Long.parseLong(rawVertexId);
} else if (idStrategy == IdStrategy.CUSTOMIZE_UUID) {
return UUID.fromString(rawVertexId);
}
} catch (Exception e) {
throw new ExternalException("gremlin.convert-vertex-id.failed", e, rawVertexId, idStrategy);
}
assert idStrategy == IdStrategy.PRIMARY_KEY || idStrategy == IdStrategy.CUSTOMIZE_STRING;
return rawVertexId;
}
use of com.baidu.hugegraph.exception.ExternalException in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelService method get.
public EdgeLabelEntity get(String name, int connId) {
HugeClient client = this.client(connId);
try {
EdgeLabel edgeLabel = client.schema().getEdgeLabel(name);
List<IndexLabel> indexLabels = client.schema().getIndexLabels();
return convert(edgeLabel, indexLabels);
} catch (ServerException e) {
if (e.status() == Constant.STATUS_NOT_FOUND) {
throw new ExternalException("schema.edgelabel.not-exist", e, name);
}
throw new ExternalException("schema.edgelabel.get.failed", e, name);
}
}
use of com.baidu.hugegraph.exception.ExternalException in project incubator-hugegraph-toolchain by apache.
the class VertexLabelService method reuse.
public void reuse(ConflictDetail detail, int connId) {
// Assume that the conflict detail is valid
Ex.check(!detail.hasConflict(), "schema.cannot-reuse-conflict");
HugeClient client = this.client(connId);
List<PropertyKey> propertyKeys = this.pkService.filter(detail, client);
if (!propertyKeys.isEmpty()) {
try {
this.pkService.addBatch(propertyKeys, client);
} catch (Exception e) {
throw new ExternalException("schema.propertykey.reuse.failed", e);
}
}
List<VertexLabel> vertexLabels = this.filter(detail, client);
// Filter propertykeys and propertyindexes
if (!vertexLabels.isEmpty()) {
try {
this.addBatch(vertexLabels, client);
} catch (Exception e) {
this.pkService.removeBatch(propertyKeys, client);
throw new ExternalException("schema.vertexlabel.reuse.failed", e);
}
}
List<IndexLabel> indexLabels = this.piService.filter(detail, client);
if (!indexLabels.isEmpty()) {
try {
this.piService.addBatch(indexLabels, client);
} catch (Exception e) {
this.removeBatch(vertexLabels, client);
this.pkService.removeBatch(propertyKeys, client);
throw new ExternalException("schema.propertyindex.reuse.failed", e);
}
}
}
use of com.baidu.hugegraph.exception.ExternalException in project incubator-hugegraph-toolchain by apache.
the class LoadTaskController method reason.
@GetMapping("{id}/reason")
public Response reason(@PathVariable("connId") int connId, @PathVariable("jobId") int jobId, @PathVariable("id") int id) {
LoadTask task = this.service.get(id);
if (task == null) {
throw new ExternalException("load.task.not-exist.id", id);
}
JobManager jobEntity = this.jobService.get(jobId);
Ex.check(jobEntity != null, "job-manager.not-exist.id", jobId);
Integer fileId = task.getFileId();
FileMapping mapping = this.fmService.get(fileId);
String reason = this.service.readLoadFailedReason(mapping);
return Response.builder().status(Constant.STATUS_OK).data(reason).build();
}
use of com.baidu.hugegraph.exception.ExternalException in project incubator-hugegraph-toolchain by apache.
the class LoadTaskController method delete.
@DeleteMapping("{id}")
public void delete(@PathVariable("id") int id) {
LoadTask task = this.service.get(id);
if (task == null) {
throw new ExternalException("load.task.not-exist.id", id);
}
this.service.remove(id);
}
Aggregations