Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
d3bca39f
Commit
d3bca39f
authored
Oct 28, 2016
by
Suma Shivaprasad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1253 Extract error codes into AtlasErrorCode Enum (apoorvnaik via sumasai)
parent
69af0ae7
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
96 additions
and
76 deletions
+96
-76
AtlasErrorCode.java
intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
+14
-0
AtlasClassificationType.java
...n/java/org/apache/atlas/type/AtlasClassificationType.java
+12
-12
AtlasEntityType.java
.../src/main/java/org/apache/atlas/type/AtlasEntityType.java
+11
-11
AtlasStructType.java
.../src/main/java/org/apache/atlas/type/AtlasStructType.java
+36
-29
AtlasTypeRegistry.java
...rc/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
+9
-8
release-log.txt
release-log.txt
+1
-0
AtlasStructDefStoreV1.java
...tlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
+10
-12
AtlasTypeDefGraphStoreV1.java
...s/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
+3
-4
No files found.
intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
View file @
d3bca39f
...
...
@@ -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}"
),
...
...
intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java
View file @
d3bca39f
...
...
@@ -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
()))
{
...
...
intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
View file @
d3bca39f
...
...
@@ -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
()))
{
...
...
intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
View file @
d3bca39f
...
...
@@ -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
(
Atlas
StructDef
.
Atlas
ConstraintDef
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
));
...
...
intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
View file @
d3bca39f
...
...
@@ -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
);
}
}
...
...
release-log.txt
View file @
d3bca39f
...
...
@@ -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)
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
View file @
d3bca39f
...
...
@@ -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
;
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
View file @
d3bca39f
...
...
@@ -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
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment