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
41839141
Commit
41839141
authored
Mar 24, 2017
by
apoorvnaik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1681 - Added type validations for compatibility with legacy typesystem
parent
1aa38090
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
21 deletions
+31
-21
AtlasErrorCode.java
intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
+1
-0
AtlasClassificationDefStoreV1.java
...ository/store/graph/v1/AtlasClassificationDefStoreV1.java
+1
-5
AtlasEntityDefStoreV1.java
...tlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
+1
-5
AtlasEnumDefStoreV1.java
.../atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java
+11
-5
AtlasStructDefStoreV1.java
...tlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
+17
-6
No files found.
intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
View file @
41839141
...
...
@@ -69,6 +69,7 @@ public enum AtlasErrorCode {
INVALID_VALUE
(
400
,
"ATLAS-400-00-028"
,
"invalid value: {0}"
),
BAD_REQUEST
(
400
,
"ATLAS-400-00-029"
,
"{0}"
),
PARAMETER_PARSING_FAILED
(
400
,
"ATLAS-400-00-02A"
,
"Parameter parsing failed at: {0}"
),
MISSING_MANDATORY_ATTRIBUTE
(
400
,
"ATLAS-400-00-02B"
,
"Mandatory field {0}.{1} has empty/null value"
),
// All Not found enums go here
TYPE_NAME_NOT_FOUND
(
404
,
"ATLAS-404-00-001"
,
"Given typename {0} was invalid"
),
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java
View file @
41839141
...
...
@@ -20,19 +20,15 @@ package org.apache.atlas.repository.store.graph.v1;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.SearchFilter
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef.AtlasClassificationDefs
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.repository.store.graph.AtlasClassificationDefStore
;
import
org.apache.atlas.repository.util.FilterUtil
;
import
org.apache.atlas.type.AtlasClassificationType
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeUtil
;
import
org.apache.atlas.typesystem.types.DataTypes.TypeCategory
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -340,7 +336,7 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
private
void
updateVertexPreCreate
(
AtlasClassificationDef
classificationDef
,
AtlasClassificationType
classificationType
,
AtlasVertex
vertex
)
{
AtlasVertex
vertex
)
throws
AtlasBaseException
{
AtlasStructDefStoreV1
.
updateVertexPreCreate
(
classificationDef
,
classificationType
,
vertex
,
typeDefStore
);
}
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
View file @
41839141
...
...
@@ -19,19 +19,15 @@ package org.apache.atlas.repository.store.graph.v1;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.SearchFilter
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.model.typedef.AtlasEntityDef.AtlasEntityDefs
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.repository.store.graph.AtlasEntityDefStore
;
import
org.apache.atlas.repository.util.FilterUtil
;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeUtil
;
import
org.apache.atlas.typesystem.types.DataTypes.TypeCategory
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -336,7 +332,7 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
}
}
private
void
updateVertexPreCreate
(
AtlasEntityDef
entityDef
,
AtlasEntityType
entityType
,
AtlasVertex
vertex
)
{
private
void
updateVertexPreCreate
(
AtlasEntityDef
entityDef
,
AtlasEntityType
entityType
,
AtlasVertex
vertex
)
throws
AtlasBaseException
{
AtlasStructDefStoreV1
.
updateVertexPreCreate
(
entityDef
,
entityType
,
vertex
,
typeDefStore
);
}
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java
View file @
41839141
...
...
@@ -19,14 +19,11 @@ package org.apache.atlas.repository.store.graph.v1;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.SearchFilter
;
import
org.apache.atlas.model.typedef.AtlasEnumDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumDefs
;
import
org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.repository.store.graph.AtlasEnumDefStore
;
import
org.apache.atlas.repository.util.FilterUtil
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeUtil
;
import
org.apache.atlas.typesystem.types.DataTypes.TypeCategory
;
...
...
@@ -250,15 +247,24 @@ public class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1 implements Atla
}
}
private
void
toVertex
(
AtlasEnumDef
enumDef
,
AtlasVertex
vertex
)
{
private
void
toVertex
(
AtlasEnumDef
enumDef
,
AtlasVertex
vertex
)
throws
AtlasBaseException
{
if
(
CollectionUtils
.
isEmpty
(
enumDef
.
getElementDefs
()))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
MISSING_MANDATORY_ATTRIBUTE
,
enumDef
.
getName
(),
"values"
);
}
List
<
String
>
values
=
new
ArrayList
<>(
enumDef
.
getElementDefs
().
size
());
for
(
AtlasEnumElementDef
element
:
enumDef
.
getElementDefs
())
{
// Validate the enum element
if
(
StringUtils
.
isEmpty
(
element
.
getValue
())
||
null
==
element
.
getOrdinal
())
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
MISSING_MANDATORY_ATTRIBUTE
,
enumDef
.
getName
(),
"elementValue"
);
}
String
elemKey
=
AtlasGraphUtilsV1
.
getTypeDefPropertyKey
(
enumDef
,
element
.
getValue
());
AtlasGraphUtilsV1
.
setProperty
(
vertex
,
elemKey
,
element
.
getOrdinal
());
if
(
StringUtils
.
isNo
ne
Blank
(
element
.
getDescription
()))
{
if
(
StringUtils
.
isNo
t
Blank
(
element
.
getDescription
()))
{
String
descKey
=
AtlasGraphUtilsV1
.
getTypeDefPropertyKey
(
elemKey
,
"description"
);
AtlasGraphUtilsV1
.
setProperty
(
vertex
,
descKey
,
element
.
getDescription
());
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
View file @
41839141
...
...
@@ -17,18 +17,16 @@
*/
package
org
.
apache
.
atlas
.
repository
.
store
.
graph
.
v1
;
import
com.google.common.annotations.VisibleForTesting
;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.exception.AtlasBaseException
;
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
org.apache.atlas.model.typedef.AtlasStructDef.AtlasStructDefs
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.graph.GraphHelper
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.repository.store.graph.AtlasStructDefStore
;
import
org.apache.atlas.repository.util.FilterUtil
;
import
org.apache.atlas.type.AtlasStructType
;
import
org.apache.atlas.type.AtlasStructType.AtlasAttribute
;
import
org.apache.atlas.type.AtlasType
;
...
...
@@ -43,8 +41,6 @@ import org.codehaus.jettison.json.JSONException;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.google.common.annotations.VisibleForTesting
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Iterator
;
...
...
@@ -358,10 +354,18 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
}
public
static
void
updateVertexPreCreate
(
AtlasStructDef
structDef
,
AtlasStructType
structType
,
AtlasVertex
vertex
,
AtlasTypeDefGraphStoreV1
typeDefStore
)
{
AtlasVertex
vertex
,
AtlasTypeDefGraphStoreV1
typeDefStore
)
throws
AtlasBaseException
{
List
<
String
>
attrNames
=
new
ArrayList
<>(
structDef
.
getAttributeDefs
().
size
());
for
(
AtlasAttributeDef
attributeDef
:
structDef
.
getAttributeDefs
())
{
// Validate the mandatory features of an attribute (compatibility with legacy type system)
if
(
StringUtils
.
isEmpty
(
attributeDef
.
getName
()))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
MISSING_MANDATORY_ATTRIBUTE
,
structDef
.
getName
(),
"name"
);
}
if
(
StringUtils
.
isEmpty
(
attributeDef
.
getTypeName
()))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
MISSING_MANDATORY_ATTRIBUTE
,
structDef
.
getName
(),
"typeName"
);
}
String
propertyKey
=
AtlasGraphUtilsV1
.
getTypeDefPropertyKey
(
structDef
,
attributeDef
.
getName
());
AtlasGraphUtilsV1
.
setProperty
(
vertex
,
propertyKey
,
toJsonFromAttribute
(
structType
.
getAttribute
(
attributeDef
.
getName
())));
...
...
@@ -405,6 +409,13 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
throw
new
AtlasBaseException
(
AtlasErrorCode
.
CANNOT_ADD_MANDATORY_ATTRIBUTE
,
structDef
.
getName
(),
attributeDef
.
getName
());
}
}
// Validate the mandatory features of an attribute (compatibility with legacy type system)
if
(
StringUtils
.
isEmpty
(
attributeDef
.
getName
()))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
MISSING_MANDATORY_ATTRIBUTE
,
structDef
.
getName
(),
"name"
);
}
if
(
StringUtils
.
isEmpty
(
attributeDef
.
getTypeName
()))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
MISSING_MANDATORY_ATTRIBUTE
,
structDef
.
getName
(),
"typeName"
);
}
String
propertyKey
=
AtlasGraphUtilsV1
.
getTypeDefPropertyKey
(
structDef
,
attributeDef
.
getName
());
...
...
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