Commit a910609d by Madhan Neethiraj

ATLAS-3136: assigning a term to an invalid entity guid throws 500, instead of 400

parent 06a3fd3f
...@@ -59,7 +59,7 @@ public interface AtlasRelationshipStore { ...@@ -59,7 +59,7 @@ public interface AtlasRelationshipStore {
AtlasEdge getOrCreate(AtlasVertex end1Vertex, AtlasVertex end2Vertex, AtlasRelationship relationship) throws AtlasBaseException; AtlasEdge getOrCreate(AtlasVertex end1Vertex, AtlasVertex end2Vertex, AtlasRelationship relationship) throws AtlasBaseException;
AtlasEdge getRelationship(AtlasVertex end1Vertex, AtlasVertex end2Vertex, AtlasRelationship relationship); AtlasEdge getRelationship(AtlasVertex end1Vertex, AtlasVertex end2Vertex, AtlasRelationship relationship) throws AtlasBaseException;
AtlasEdge createRelationship(AtlasVertex end1Vertex, AtlasVertex end2Vertex, AtlasRelationship relationship) throws AtlasBaseException; AtlasEdge createRelationship(AtlasVertex end1Vertex, AtlasVertex end2Vertex, AtlasRelationship relationship) throws AtlasBaseException;
......
...@@ -294,7 +294,7 @@ public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore { ...@@ -294,7 +294,7 @@ public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore {
} }
@Override @Override
public AtlasEdge getRelationship(AtlasVertex fromVertex, AtlasVertex toVertex, AtlasRelationship relationship) { public AtlasEdge getRelationship(AtlasVertex fromVertex, AtlasVertex toVertex, AtlasRelationship relationship) throws AtlasBaseException {
String relationshipLabel = getRelationshipEdgeLabel(fromVertex, toVertex, relationship.getTypeName()); String relationshipLabel = getRelationshipEdgeLabel(fromVertex, toVertex, relationship.getTypeName());
return getRelationshipEdge(fromVertex, toVertex, relationshipLabel); return getRelationshipEdge(fromVertex, toVertex, relationshipLabel);
...@@ -802,12 +802,25 @@ public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore { ...@@ -802,12 +802,25 @@ public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore {
return ret; return ret;
} }
private String getRelationshipEdgeLabel(AtlasVertex fromVertex, AtlasVertex toVertex, String relationshipTypeName) { private String getRelationshipEdgeLabel(AtlasVertex fromVertex, AtlasVertex toVertex, String relationshipTypeName) throws AtlasBaseException {
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("getRelationshipEdgeLabel({})", relationshipTypeName); LOG.debug("getRelationshipEdgeLabel({})", relationshipTypeName);
} }
AtlasRelationshipType relationshipType = typeRegistry.getRelationshipTypeByName(relationshipTypeName); AtlasRelationshipType relationshipType = typeRegistry.getRelationshipTypeByName(relationshipTypeName);
if (relationshipType == null) {
throw new AtlasBaseException(AtlasErrorCode.INVALID_VALUE, "unknown relationship type'" + relationshipTypeName + "'");
}
if (fromVertex == null) {
throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_END_IS_NULL, relationshipType.getEnd1Type().getTypeName());
}
if (toVertex == null) {
throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_END_IS_NULL, relationshipType.getEnd2Type().getTypeName());
}
String ret = relationshipType.getRelationshipLabel(); String ret = relationshipType.getRelationshipLabel();
AtlasRelationshipEndDef endDef1 = relationshipType.getRelationshipDef().getEndDef1(); AtlasRelationshipEndDef endDef1 = relationshipType.getRelationshipDef().getEndDef1();
AtlasRelationshipEndDef endDef2 = relationshipType.getRelationshipDef().getEndDef2(); AtlasRelationshipEndDef endDef2 = relationshipType.getRelationshipDef().getEndDef2();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment