You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by su...@apache.org on 2016/10/28 23:47:29 UTC
incubator-atlas git commit: ATLAS-1253 Extract error codes into
AtlasErrorCode Enum (apoorvnaik via sumasai)
Repository: incubator-atlas
Updated Branches:
refs/heads/master 69af0ae77 -> d3bca39fd
ATLAS-1253 Extract error codes into AtlasErrorCode Enum (apoorvnaik via sumasai)
Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/d3bca39f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/d3bca39f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/d3bca39f
Branch: refs/heads/master
Commit: d3bca39fd90b77b28902fbdc5a9050a204ec8898
Parents: 69af0ae
Author: Suma Shivaprasad <su...@gmail.com>
Authored: Fri Oct 28 16:46:54 2016 -0700
Committer: Suma Shivaprasad <su...@gmail.com>
Committed: Fri Oct 28 16:46:54 2016 -0700
----------------------------------------------------------------------
.../java/org/apache/atlas/AtlasErrorCode.java | 14 +++++
.../atlas/type/AtlasClassificationType.java | 24 ++++----
.../org/apache/atlas/type/AtlasEntityType.java | 22 +++----
.../org/apache/atlas/type/AtlasStructType.java | 65 +++++++++++---------
.../apache/atlas/type/AtlasTypeRegistry.java | 17 ++---
release-log.txt | 1 +
.../store/graph/v1/AtlasStructDefStoreV1.java | 22 +++----
.../graph/v1/AtlasTypeDefGraphStoreV1.java | 7 +--
8 files changed, 96 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d3bca39f/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 ce68e6e..caffb6a 100644
--- a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
+++ b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
@@ -29,6 +29,20 @@ public enum AtlasErrorCode {
NO_SEARCH_RESULTS(204, "ATLAS2041E", "Given search filter did not yield any results"),
UNKNOWN_TYPE(400, "ATLAS4001E", "Unknown type {0} for {1}.{2}"),
+ CIRCULAR_REFERENCE(400, "ATLAS4002E", "{0}: invalid supertypes - circular reference back to self {1}"),
+ INCOMPATIBLE_SUPERTYPE(400, "ATLAS4003E", "{0}: incompatible supertype {1}"),
+ UNKNOWN_CONSTRAINT(400, "ATLAS4004E", "{0}.{1}: unknown constraint {1}"),
+ UNSUPPORTED_CONSTRAINT(400, "ATLAS4005E", "{0}.{1} : {2} constraint not supported"),
+ CONSTRAINT_NOT_SATISFIED(400, "ATLAS4006E", "{0}.{1} : {2} incompatible attribute type {3}"),
+ CONSTRAINT_MISSING_PARAMS(400, "ATLAS4007E", "{0}.{1} : invalid constraint. missing parameter {2} in {3}. params={4}"),
+ CONSTRAINT_NOT_EXIST(400, "ATLAS4008E", "{0}.{1} : invalid constraint. {2} {3}.{4} does not exist"),
+ CONSTRAINT_NOT_MATCHED(400, "ATLAS4009E", "{0}.{1} : invalid constraint. Data type of {2} {3}.{4} should be {5}, but found {6}"),
+ UNKNOWN_TYPENAME(400, "ATLAS40010E", "{0}: Unknown typename"),
+ CONSTRAINT_NOT_SUPPORTED_ON_MAP_TYPE(400, "ATLAS40011E", "{0}.{1} : constraints not supported on map type {2}"),
+ CANNOT_ADD_MANDATORY_ATTRIBUTE(400, "ATLAS40012E", "{0}.{1} : can not add mandatory attribute"),
+ ATTRIBUTE_DELETION_NOT_SUPPORTED(400, "ATLAS40013E", "{0}.{1} : attribute delete not supported"),
+ SUPERTYPE_REMOVAL_NOT_SUPPORTED(400, "ATLAS40014E", "superType remove not supported"),
+
TYPE_NAME_NOT_FOUND(404, "ATLAS4041E", "Given typename {0} was invalid"),
TYPE_GUID_NOT_FOUND(404, "ATLAS4042E", "Given type guid {0} was invalid"),
EMPTY_RESULTS(404, "ATLAS4044E", "No result found for {0}"),
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d3bca39f/intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java b/intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java
index 56ff803..fa4ca20 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java
@@ -18,6 +18,14 @@
package org.apache.atlas.type;
+import org.apache.atlas.AtlasErrorCode;
+import org.apache.atlas.exception.AtlasBaseException;
+import org.apache.atlas.model.instance.AtlasClassification;
+import org.apache.atlas.model.typedef.AtlasClassificationDef;
+import org.apache.commons.collections.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@@ -25,14 +33,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.atlas.exception.AtlasBaseException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.atlas.model.instance.AtlasClassification;
-import org.apache.atlas.model.typedef.AtlasClassificationDef;
-import org.apache.commons.collections.CollectionUtils;
-
/**
* class that implements behaviour of a classification-type.
@@ -73,8 +73,8 @@ public class AtlasClassificationType extends AtlasStructType {
if (superType instanceof AtlasClassificationType) {
s.add((AtlasClassificationType)superType);
} else {
- throw new AtlasBaseException(superTypeName + ": incompatible supertype in classification "
- + classificationDef.getName());
+ throw new AtlasBaseException(AtlasErrorCode.INCOMPATIBLE_SUPERTYPE, superTypeName,
+ classificationDef.getName());
}
}
@@ -201,8 +201,8 @@ public class AtlasClassificationType extends AtlasStructType {
private void collectAllSuperTypes(List<String> subTypes, Set<String> superTypes, AtlasTypeRegistry typeRegistry)
throws AtlasBaseException {
if (subTypes.contains(classificationDef.getName())) {
- throw new AtlasBaseException(classificationDef.getName()
- + ": invalid supertypes - circular reference back to self " + subTypes);
+ throw new AtlasBaseException(AtlasErrorCode.CIRCULAR_REFERENCE,
+ classificationDef.getName(), subTypes.toString());
}
if (CollectionUtils.isNotEmpty(classificationDef.getSuperTypes())) {
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d3bca39f/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java b/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
index bebfaeb..9c5ec62 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
@@ -18,13 +18,7 @@
package org.apache.atlas.type;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.typedef.AtlasEntityDef;
@@ -32,6 +26,13 @@ import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
/**
* class that implements behaviour of an entity-type.
@@ -71,8 +72,8 @@ public class AtlasEntityType extends AtlasStructType {
if (superType instanceof AtlasEntityType) {
s.add((AtlasEntityType)superType);
} else {
- throw new AtlasBaseException(superTypeName + ": incompatible supertype in entity "
- + entityDef.getName());
+ throw new AtlasBaseException(AtlasErrorCode.INCOMPATIBLE_SUPERTYPE, superTypeName,
+ entityDef.getName());
}
}
@@ -201,8 +202,7 @@ public class AtlasEntityType extends AtlasStructType {
private void collectAllSuperTypes(List<String> subTypes, Set<String> superTypes, AtlasTypeRegistry typeRegistry)
throws AtlasBaseException {
if (subTypes.contains(entityDef.getName())) {
- throw new AtlasBaseException(entityDef.getName()
- + ": invalid supertypes - circular reference back to self " + subTypes);
+ throw new AtlasBaseException(AtlasErrorCode.CIRCULAR_REFERENCE, entityDef.getName(), subTypes.toString());
}
if (CollectionUtils.isNotEmpty(entityDef.getSuperTypes())) {
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d3bca39f/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java b/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
index fa0b02a..78b29fd 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
@@ -17,22 +17,28 @@
*/
package org.apache.atlas.type;
-import java.util.*;
-
+import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.instance.AtlasStruct;
import org.apache.atlas.model.typedef.AtlasStructDef;
-import org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef;
-import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_PARAM_REF_ATTRIBUTE;
-import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_FOREIGN_KEY;
-import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_MAPPED_FROM_REF;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality;
+import org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_PARAM_REF_ATTRIBUTE;
+import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_MAPPED_FROM_REF;
+
/**
* class that implements behaviour of a struct-type.
@@ -332,20 +338,20 @@ public class AtlasStructType extends AtlasType {
return;
}
- for (AtlasStructDef.AtlasConstraintDef constraintDef : attribDef.getConstraintDefs()) {
+ for (AtlasConstraintDef constraintDef : attribDef.getConstraintDefs()) {
String constraintType = constraintDef != null ? constraintDef.getType() : null;
if (StringUtils.isBlank(constraintType)) {
continue;
}
- if (constraintType.equals(CONSTRAINT_TYPE_FOREIGN_KEY)) {
+ if (constraintType.equals(AtlasConstraintDef.CONSTRAINT_TYPE_FOREIGN_KEY)) {
resolveForeignKeyConstraint(attribDef, constraintDef, attribType);
} else if (constraintType.equals(CONSTRAINT_TYPE_MAPPED_FROM_REF)) {
resolveMappedFromRefConstraint(attribDef, constraintDef, attribType);
} else {
- throw new AtlasBaseException(getTypeName() + "." + attribDef.getName()
- + ": unknown constraint " + constraintType);
+ throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_CONSTRAINT, constraintType,
+ getTypeName(), attribDef.getName());
}
}
}
@@ -358,8 +364,8 @@ public class AtlasStructType extends AtlasType {
private void resolveForeignKeyConstraint(AtlasAttributeDef attribDef, AtlasConstraintDef constraintDef,
AtlasType attribType) throws AtlasBaseException {
if (this.getTypeCategory() != TypeCategory.ENTITY) {
- throw new AtlasBaseException(getTypeName() + "." + attribDef.getName() + ": "
- + AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_FOREIGN_KEY + " constraint not supported");
+ throw new AtlasBaseException(AtlasErrorCode.UNSUPPORTED_CONSTRAINT,
+ AtlasConstraintDef.CONSTRAINT_TYPE_FOREIGN_KEY , getTypeName(), attribDef.getName());
}
if (attribType.getTypeCategory() == TypeCategory.ARRAY) {
@@ -367,9 +373,9 @@ public class AtlasStructType extends AtlasType {
}
if (attribType.getTypeCategory() != TypeCategory.ENTITY) {
- throw new AtlasBaseException(getTypeName() + "." + attribDef.getName() + ": "
- + AtlasConstraintDef.CONSTRAINT_TYPE_FOREIGN_KEY + " incompatible attribute type "
- + attribType.getTypeName());
+ throw new AtlasBaseException(AtlasErrorCode.CONSTRAINT_NOT_SATISFIED,
+ getTypeName(), attribDef.getName(), AtlasConstraintDef.CONSTRAINT_TYPE_FOREIGN_KEY,
+ attribType.getTypeName());
}
foreignKeyAttributes.add(attribDef.getName());
@@ -385,8 +391,8 @@ public class AtlasStructType extends AtlasType {
AtlasType attribType) throws AtlasBaseException {
if (this.getTypeCategory() != TypeCategory.ENTITY) {
- throw new AtlasBaseException(getTypeName() + "." + attribDef.getName() + ": "
- + CONSTRAINT_TYPE_MAPPED_FROM_REF + " constraint not supported");
+ throw new AtlasBaseException(AtlasErrorCode.UNSUPPORTED_CONSTRAINT, getTypeName(),
+ attribDef.getName(), CONSTRAINT_TYPE_MAPPED_FROM_REF);
}
if (attribType.getTypeCategory() == TypeCategory.ARRAY) {
@@ -394,32 +400,33 @@ public class AtlasStructType extends AtlasType {
}
if (attribType.getTypeCategory() != TypeCategory.ENTITY) {
- throw new AtlasBaseException(getTypeName() + "." + attribDef.getName() + ": "
- + CONSTRAINT_TYPE_MAPPED_FROM_REF + " incompatible attribute type "
- + attribType.getTypeName());
+ throw new AtlasBaseException(AtlasErrorCode.CONSTRAINT_NOT_SATISFIED, getTypeName(),
+ attribDef.getName(), CONSTRAINT_TYPE_MAPPED_FROM_REF, attribDef.getTypeName());
}
String refAttribName = AtlasTypeUtil.getStringValue(constraintDef.getParams(), CONSTRAINT_PARAM_REF_ATTRIBUTE);
if (StringUtils.isBlank(refAttribName)) {
- throw new AtlasBaseException(getTypeName() + "." + attribDef.getName() + ": "
- + " invalid constraint. missing parameter " + CONSTRAINT_PARAM_REF_ATTRIBUTE
- + " in " + CONSTRAINT_TYPE_MAPPED_FROM_REF + ". params=" + constraintDef.getParams());
+ throw new AtlasBaseException(AtlasErrorCode.CONSTRAINT_MISSING_PARAMS,
+ getTypeName(), attribDef.getName(),
+ CONSTRAINT_PARAM_REF_ATTRIBUTE, CONSTRAINT_TYPE_MAPPED_FROM_REF,
+ String.valueOf(constraintDef.getParams()));
}
AtlasStructType structType = (AtlasStructType)attribType;
AtlasAttributeDef refAttrib = structType.getAttributeDef(refAttribName);
if (refAttrib == null) {
- throw new AtlasBaseException(getTypeName() + "." + attribDef.getName() + ": invalid constraint. "
- + CONSTRAINT_PARAM_REF_ATTRIBUTE + " " + structType.getTypeName() + "." + refAttribName
- + " does not exist");
+ throw new AtlasBaseException(AtlasErrorCode.CONSTRAINT_NOT_EXIST,
+ getTypeName(), attribDef.getName(),
+ CONSTRAINT_PARAM_REF_ATTRIBUTE, structType.getTypeName(), refAttribName);
}
if (!StringUtils.equals(getTypeName(), refAttrib.getTypeName())) {
- throw new AtlasBaseException(getTypeName() + "." + attribDef.getName() + ": invalid constraint. Datatype"
- + " of " + CONSTRAINT_PARAM_REF_ATTRIBUTE + " " + structType.getTypeName() + "." + refAttribName
- + " should be " + getTypeName() + ", but found " + refAttrib.getTypeName());
+ throw new AtlasBaseException(AtlasErrorCode.CONSTRAINT_NOT_MATCHED,
+ getTypeName(), attribDef.getName(),
+ CONSTRAINT_PARAM_REF_ATTRIBUTE, structType.getTypeName(), refAttribName,
+ getTypeName(), refAttrib.getTypeName());
}
mappedFromRefAttributes.put(attribDef.getName(), new TypeAttributePair(attribType.getTypeName(), refAttribName));
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d3bca39f/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java b/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
index bfdf8ea..95a5054 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
@@ -18,6 +18,8 @@
package org.apache.atlas.type;
import com.sun.jersey.spi.resource.Singleton;
+
+import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.model.typedef.AtlasClassificationDef;
@@ -25,13 +27,6 @@ import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.model.typedef.AtlasEnumDef;
import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.model.typedef.AtlasTypesDef;
-
-import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_ARRAY_PREFIX;
-import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_ARRAY_SUFFIX;
-import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_MAP_PREFIX;
-import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_MAP_SUFFIX;
-import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_MAP_KEY_VAL_SEP;
-
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
@@ -42,6 +37,12 @@ import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_ARRAY_PREFIX;
+import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_ARRAY_SUFFIX;
+import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_MAP_KEY_VAL_SEP;
+import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_MAP_PREFIX;
+import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_MAP_SUFFIX;
+
/**
* registry for all types defined in Atlas.
*/
@@ -84,7 +85,7 @@ public class AtlasTypeRegistry {
ret = new AtlasMapType(keyTypeName, valueTypeName, this);
} else {
- throw new AtlasBaseException(typeName + ": unknown typename");
+ throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_TYPENAME, typeName);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d3bca39f/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 67e83a9..9f440f2 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES:
+ATLAS-1253 Extract error codes into AtlasErrorCode Enum (apoorvnaik via sumasai)
ATLAS-1195 Clean up DSL Translation (jnhagelb via dkantor)
ATLAS-1139 Parameter name of a HDFS DataSet entity should contain filesystem path (svimal2106 via sumasai)
ATLAS-1200 Error Catalog enhancement (apoorvnaik via sumasai)
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d3bca39f/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
index f63adbb..0dd7164 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
@@ -23,12 +23,6 @@ import org.apache.atlas.model.SearchFilter;
import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef;
-
-import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_PARAM_ON_DELETE;
-import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_PARAM_VAL_CASCADE;
-import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_FOREIGN_KEY;
-import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_MAPPED_FROM_REF;
-
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasStructDefs;
import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graphdb.AtlasVertex;
@@ -52,6 +46,11 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_PARAM_ON_DELETE;
+import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_PARAM_VAL_CASCADE;
+import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_FOREIGN_KEY;
+import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_MAPPED_FROM_REF;
+
/**
* StructDef store in v1 format.
*/
@@ -409,8 +408,8 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
if (CollectionUtils.isNotEmpty(currAttrNames)) {
for (String currAttrName : currAttrNames) {
if (!attrNames.contains(currAttrName)) {
- throw new AtlasBaseException(structDef.getName() + "." + currAttrName +
- ": attribute delete not supported");
+ throw new AtlasBaseException(AtlasErrorCode.ATTRIBUTE_DELETION_NOT_SUPPORTED,
+ structDef.getName(), currAttrName);
}
}
}
@@ -423,8 +422,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
if (CollectionUtils.isEmpty(currAttrNames) || !currAttrNames.contains(attributeDef.getName())) {
// new attribute - only allow if optional
if (!attributeDef.isOptional()) {
- throw new AtlasBaseException(structDef.getName() + "." + attributeDef.getName()
- + ": can not add mandatory attribute");
+ throw new AtlasBaseException(AtlasErrorCode.CANNOT_ADD_MANDATORY_ATTRIBUTE, structDef.getName(), attributeDef.getName());
}
}
@@ -557,8 +555,8 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
if (StringUtils.isNotBlank(reverseAttribName) || isComposite) {
if (AtlasTypeUtil.isMapType(attrTypeName)) {
- throw new AtlasBaseException(structDef.getName() + "." + ret.getName()
- + ": constraints not supported on map type " + attrTypeName);
+ throw new AtlasBaseException(AtlasErrorCode.CONSTRAINT_NOT_SUPPORTED_ON_MAP_TYPE,
+ structDef.getName(), ret.getName(), attrTypeName);
}
String refAttributeName = null;
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d3bca39f/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
index 80feaf6..1f40f87 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
@@ -18,9 +18,8 @@
package org.apache.atlas.repository.store.graph.v1;
import com.google.common.base.Preconditions;
-
import com.google.inject.Inject;
-import org.apache.atlas.AtlasConstants;
+
import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
@@ -341,7 +340,7 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
if (CollectionUtils.isNotEmpty(superTypes)) {
if (! superTypes.containsAll(currentSuperTypes)) {
- throw new AtlasBaseException("superType remove not supported");
+ throw new AtlasBaseException(AtlasErrorCode.SUPERTYPE_REMOVAL_NOT_SUPPORTED);
}
for (String superType : superTypes) {
@@ -350,7 +349,7 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
getOrCreateEdge(vertex, superTypeVertex, AtlasGraphUtilsV1.SUPERTYPE_EDGE_LABEL);
}
} else if (CollectionUtils.isNotEmpty(currentSuperTypes)) {
- throw new AtlasBaseException("superType remove not supported");
+ throw new AtlasBaseException(AtlasErrorCode.SUPERTYPE_REMOVAL_NOT_SUPPORTED);
}
}