atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [13/14] incubator-atlas git commit: ATLAS-1912: fix for defects reported by Coverity scan
Date Sun, 09 Jul 2017 15:07:51 GMT
ATLAS-1912: fix for defects reported by Coverity scan

Signed-off-by: Madhan Neethiraj <madhan@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/ee8c81df
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/ee8c81df
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/ee8c81df

Branch: refs/heads/feature-odf
Commit: ee8c81df45801fa3798c19f3999b635140e835f7
Parents: 1c4e8b7
Author: David Radley <david_radley@uk.ibm.com>
Authored: Fri Jul 7 20:42:45 2017 -0700
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Fri Jul 7 20:57:37 2017 -0700

----------------------------------------------------------------------
 .../java/org/apache/atlas/AtlasErrorCode.java   |  1 +
 .../graph/v1/AtlasRelationshipDefStoreV1.java   | 26 +++++++++++++-------
 2 files changed, 18 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/ee8c81df/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
index 73dd33a..e8afed1 100644
--- a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
+++ b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
@@ -100,6 +100,7 @@ public enum AtlasErrorCode {
     INSTANCE_NOT_FOUND(404, "ATLAS-404-00-00B", "Given instance is invalid/not found: {0}"),
     RELATIONSHIP_GUID_NOT_FOUND(404, "ATLAS-404-00-00C", "Given relationship guid {0} is
invalid/not found"),
     RELATIONSHIP_CRUD_INVALID_PARAMS(404, "ATLAS-404-00-00D", "Invalid relationship creation/updation
parameters passed : {0}"),
+    RELATIONSHIPDEF_END_TYPE_NAME_NOT_FOUND(404, "ATLAS-404-00-00E", "RelationshipDef {0}
endDef typename {0} cannot be found"),
     // All data conflict errors go here
     TYPE_ALREADY_EXISTS(409, "ATLAS-409-00-001", "Given type {0} already exists"),
     TYPE_HAS_REFERENCES(409, "ATLAS-409-00-002", "Given type {0} has references"),

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/ee8c81df/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipDefStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipDefStoreV1.java
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipDefStoreV1.java
index bd7416e..ddf0af9 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipDefStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipDefStoreV1.java
@@ -78,15 +78,23 @@ public class AtlasRelationshipDefStoreV1 extends AtlasAbstractDefStoreV1
impleme
 
         updateVertexPreCreate(relationshipDef, (AtlasRelationshipType) type, relationshipDefVertex);
 
-        final AtlasRelationshipEndDef endDef1 = relationshipDef.getEndDef1();
-        final String type1 = endDef1.getType();
-        final AtlasRelationshipEndDef endDef2 = relationshipDef.getEndDef2();
-        final String type2 = endDef2.getType();
-        final String name1 = endDef1.getName();
-        final String name2 = endDef2.getName();
-        AtlasVertex end1TypeVertex = typeDefStore.findTypeVertexByName(type1);
-
-        AtlasVertex end2TypeVertex = typeDefStore.findTypeVertexByName(type2);
+        final AtlasRelationshipEndDef endDef1        = relationshipDef.getEndDef1();
+        final AtlasRelationshipEndDef endDef2        = relationshipDef.getEndDef2();
+        final String                  type1          = endDef1.getType();
+        final String                  type2          = endDef2.getType();
+        final String                  name1          = endDef1.getName();
+        final String                  name2          = endDef2.getName();
+        final AtlasVertex             end1TypeVertex = typeDefStore.findTypeVertexByName(type1);
+        final AtlasVertex             end2TypeVertex = typeDefStore.findTypeVertexByName(type2);
+
+        if (end1TypeVertex == null) {
+            throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_END_TYPE_NAME_NOT_FOUND,
relationshipDef.getName(), type1);
+        }
+
+        if (end2TypeVertex == null) {
+            throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_END_TYPE_NAME_NOT_FOUND,
relationshipDef.getName(), type2);
+        }
+
         // create an edge between the relationshipDef and each of the entityDef vertices.
         AtlasEdge edge1 = typeDefStore.getOrCreateEdge(relationshipDefVertex, end1TypeVertex,
AtlasGraphUtilsV1.RELATIONSHIPTYPE_EDGE_LABEL);
 


Mime
View raw message