throw new MissingRequest(RESOLVE_EDGES_REQUEST);
}
final KamHandle handle = request.getHandle();
if (handle == null) {
throw new RequestException("KamHandle payload is missing");
}
// Get the Dialect (may be null)
final Dialect dialect = getDialect(request.getDialect());
final org.openbel.framework.api.Kam kam = verifyKam(handle, dialect);
final List<Edge> edges = request.getEdges();
if (edges.isEmpty()) {
throw new RequestException("No edge to resolve");
}
// Sanity check the edges (see #83)
for (final Edge e : edges) {
Node src = e.getSource(), tgt = e.getTarget();
if (src == null || tgt == null) {
final String msg = "edge missing source and target nodes";
throw new RequestException(msg);
}
RelationshipType rel = e.getRelationship();
if (rel == null) {
final String msg = "edge missing relationship";
throw new RequestException(msg);
}
if (noLength(src.getLabel())) {
final String msg = "edge source node label is missing";
throw new RequestException(msg);
}
if (noLength(tgt.getLabel())) {
final String msg = "edge target node label is missing";
throw new RequestException(msg);
}
}
final ResolveEdgesResponse response = OBJECT_FACTORY
.createResolveEdgesResponse();
try {
List<KamEdge> kamEdges = resolverService.resolveEdges(kam, edges);
for (final KamEdge kamEdge : kamEdges) {
response.getKamEdges().add(kamEdge);
}
return response;
} catch (ResolverServiceException e) {
final String msg = "error resolving edges";
throw new RequestException(msg, e);
}
}