use of com.baidu.hugegraph.exception.ExternalException in project incubator-hugegraph-toolchain by apache.
the class FileMappingController method delete.
@DeleteMapping("{id}")
public void delete(@PathVariable("id") int id) {
FileMapping mapping = this.service.get(id);
if (mapping == null) {
throw new ExternalException("load.file-mapping.not-exist.id", id);
}
this.service.deleteDiskFile(mapping);
this.service.remove(id);
}
use of com.baidu.hugegraph.exception.ExternalException in project incubator-hugegraph-toolchain by apache.
the class FileMappingController method updateVertexMapping.
@PutMapping("{id}/vertex-mappings/{vmid}")
public FileMapping updateVertexMapping(@PathVariable("connId") int connId, @PathVariable("id") int id, @PathVariable("vmid") String vmId, @RequestBody VertexMapping newEntity) {
FileMapping mapping = this.service.get(id);
if (mapping == null) {
throw new ExternalException("load.file-mapping.not-exist.id", id);
}
this.checkVertexMappingValid(connId, newEntity, mapping);
VertexMapping vertexMapping = mapping.getVertexMapping(vmId);
Ex.check(vertexMapping != null, "load.file-mapping.vertex-mapping.not-exist.id", vmId);
newEntity.setId(vmId);
Set<VertexMapping> vertexMappings = mapping.getVertexMappings();
vertexMappings.remove(vertexMapping);
vertexMappings.add(newEntity);
this.service.update(mapping);
return mapping;
}
use of com.baidu.hugegraph.exception.ExternalException in project incubator-hugegraph-toolchain by apache.
the class FileMappingController method addVertexMapping.
@PostMapping("{id}/vertex-mappings")
public FileMapping addVertexMapping(@PathVariable("connId") int connId, @PathVariable("id") int id, @RequestBody VertexMapping newEntity) {
FileMapping mapping = this.service.get(id);
if (mapping == null) {
throw new ExternalException("load.file-mapping.not-exist.id", id);
}
this.checkVertexMappingValid(connId, newEntity, mapping);
newEntity.setId(HubbleUtil.generateSimpleId());
mapping.getVertexMappings().add(newEntity);
this.service.update(mapping);
return mapping;
}
use of com.baidu.hugegraph.exception.ExternalException in project incubator-hugegraph-toolchain by apache.
the class JobManagerController method update.
@PutMapping("{id}")
public JobManager update(@PathVariable("connId") int connId, @PathVariable("id") int id, @RequestBody JobManager newEntity) {
Ex.check(newEntity.getJobName().length() <= 48, "job.manager.job-name.reached-limit");
Ex.check(newEntity.getJobName() != null, () -> Constant.COMMON_NAME_PATTERN.matcher(newEntity.getJobName()).matches(), "job.manager.job-name.unmatch-regex");
Ex.check(!StringUtils.isEmpty(newEntity.getJobRemarks()), () -> Constant.COMMON_REMARK_PATTERN.matcher(newEntity.getJobRemarks()).matches(), "job.manager.job-remarks.unmatch-regex");
// Check exist Job Manager with this id
JobManager entity = this.service.get(id);
if (entity == null) {
throw new ExternalException("job-manager.not-exist.id", id);
}
if (!newEntity.getJobName().equals(entity.getJobName()) && this.service.getTask(newEntity.getJobName(), connId) != null) {
throw new InternalException("job.manager.job-name.repeated");
}
entity.setJobName(newEntity.getJobName());
entity.setJobRemarks(newEntity.getJobRemarks());
this.service.update(entity);
return entity;
}
use of com.baidu.hugegraph.exception.ExternalException in project incubator-hugegraph-toolchain by apache.
the class GraphConnectionController method update.
@PutMapping("{id}")
public GraphConnection update(@PathVariable("id") int id, @RequestBody GraphConnection newEntity) {
this.checkIdSameAsBody(id, newEntity);
this.checkParamsValid(newEntity, false);
this.checkAddressSecurity(newEntity);
// Check exist connection with this id
GraphConnection oldEntity = this.connService.get(id);
if (oldEntity == null) {
throw new ExternalException("graph-connection.not-exist.id", id);
}
GraphConnection entity = this.mergeEntity(oldEntity, newEntity);
// Make sure the updated connection doesn't conflict with exists
this.checkEntityUnique(entity, false);
this.sslService.configSSL(this.config, entity);
HugeClient client = HugeClientUtil.tryConnect(entity);
this.connService.update(entity);
this.poolService.put(entity, client);
return entity;
}
Aggregations