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
44df46cf
Commit
44df46cf
authored
8 years ago
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1614: updated v1 partial-update to perform attribute validation
parent
6fd04d9a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
4 deletions
+23
-4
AtlasErrorCode.java
intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
+1
-0
AtlasInstanceConverter.java
...e/atlas/repository/converters/AtlasInstanceConverter.java
+12
-0
DefaultMetadataService.java
...ava/org/apache/atlas/services/DefaultMetadataService.java
+6
-4
MetadataService.java
.../main/java/org/apache/atlas/services/MetadataService.java
+4
-0
No files found.
intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
View file @
44df46cf
...
@@ -66,6 +66,7 @@ public enum AtlasErrorCode {
...
@@ -66,6 +66,7 @@ public enum AtlasErrorCode {
INVALID_STRUCT_VALUE
(
400
,
"ATLAS40036E"
,
"not a valid struct value {0}"
),
INVALID_STRUCT_VALUE
(
400
,
"ATLAS40036E"
,
"not a valid struct value {0}"
),
INSTANCE_LINEAGE_INVALID_PARAMS
(
400
,
"ATLAS40037E"
,
"Invalid lineage query parameters passed {0}: {1}"
),
INSTANCE_LINEAGE_INVALID_PARAMS
(
400
,
"ATLAS40037E"
,
"Invalid lineage query parameters passed {0}: {1}"
),
ATTRIBUTE_UPDATE_NOT_SUPPORTED
(
400
,
"ATLAS40038E"
,
"{0}.{1} : attribute update not supported"
),
ATTRIBUTE_UPDATE_NOT_SUPPORTED
(
400
,
"ATLAS40038E"
,
"{0}.{1} : attribute update not supported"
),
INVALID_VALUE
(
400
,
"ATLAS40039E"
,
"invalid value: {0}"
),
// All Not found enums go here
// All Not found enums go here
TYPE_NAME_NOT_FOUND
(
404
,
"ATLAS4041E"
,
"Given typename {0} was invalid"
),
TYPE_NAME_NOT_FOUND
(
404
,
"ATLAS4041E"
,
"Given typename {0} was invalid"
),
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
View file @
44df46cf
...
@@ -49,6 +49,7 @@ import org.apache.atlas.typesystem.exception.EntityNotFoundException;
...
@@ -49,6 +49,7 @@ import org.apache.atlas.typesystem.exception.EntityNotFoundException;
import
org.apache.atlas.typesystem.exception.TraitNotFoundException
;
import
org.apache.atlas.typesystem.exception.TraitNotFoundException
;
import
org.apache.atlas.typesystem.exception.TypeNotFoundException
;
import
org.apache.atlas.typesystem.exception.TypeNotFoundException
;
import
org.apache.atlas.repository.converters.AtlasFormatConverter.ConverterContext
;
import
org.apache.atlas.repository.converters.AtlasFormatConverter.ConverterContext
;
import
org.apache.atlas.typesystem.types.ValueConversionException
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -149,6 +150,13 @@ public class AtlasInstanceConverter {
...
@@ -149,6 +150,13 @@ public class AtlasInstanceConverter {
throw
new
AtlasBaseException
(
AtlasErrorCode
.
TYPE_NAME_INVALID
,
TypeCategory
.
ENTITY
.
name
(),
referenceable
.
getTypeName
());
throw
new
AtlasBaseException
(
AtlasErrorCode
.
TYPE_NAME_INVALID
,
TypeCategory
.
ENTITY
.
name
(),
referenceable
.
getTypeName
());
}
}
// validate
try
{
metadataService
.
validateAndConvertToTypedInstance
(
referenceable
,
entityType
.
getTypeName
());
}
catch
(
AtlasException
excp
)
{
throw
toAtlasBaseException
(
excp
);
}
ConverterContext
ctx
=
new
ConverterContext
();
ConverterContext
ctx
=
new
ConverterContext
();
AtlasEntity
entity
=
converter
.
fromV1ToV2
(
referenceable
,
entityType
,
ctx
);
AtlasEntity
entity
=
converter
.
fromV1ToV2
(
referenceable
,
entityType
,
ctx
);
...
@@ -199,6 +207,10 @@ public class AtlasInstanceConverter {
...
@@ -199,6 +207,10 @@ public class AtlasInstanceConverter {
return
new
AtlasBaseException
(
AtlasErrorCode
.
TYPE_NAME_NOT_FOUND
,
e
);
return
new
AtlasBaseException
(
AtlasErrorCode
.
TYPE_NAME_NOT_FOUND
,
e
);
}
}
if
(
e
instanceof
ValueConversionException
)
{
return
new
AtlasBaseException
(
AtlasErrorCode
.
INVALID_VALUE
,
e
,
e
.
getMessage
());
}
return
new
AtlasBaseException
(
e
);
return
new
AtlasBaseException
(
e
);
}
}
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/services/DefaultMetadataService.java
View file @
44df46cf
...
@@ -42,6 +42,7 @@ import org.apache.atlas.repository.audit.EntityAuditRepository;
...
@@ -42,6 +42,7 @@ import org.apache.atlas.repository.audit.EntityAuditRepository;
import
org.apache.atlas.repository.graph.GraphHelper
;
import
org.apache.atlas.repository.graph.GraphHelper
;
import
org.apache.atlas.repository.typestore.ITypeStore
;
import
org.apache.atlas.repository.typestore.ITypeStore
;
import
org.apache.atlas.type.AtlasTypeUtil
;
import
org.apache.atlas.type.AtlasTypeUtil
;
import
org.apache.atlas.typesystem.IReferenceableInstance
;
import
org.apache.atlas.typesystem.IStruct
;
import
org.apache.atlas.typesystem.IStruct
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
import
org.apache.atlas.typesystem.ITypedStruct
;
import
org.apache.atlas.typesystem.ITypedStruct
;
...
@@ -476,7 +477,7 @@ public class DefaultMetadataService implements MetadataService, ActiveStateChang
...
@@ -476,7 +477,7 @@ public class DefaultMetadataService implements MetadataService, ActiveStateChang
newEntity
=
ParamChecker
.
notNull
(
newEntity
,
"updatedEntity cannot be null"
);
newEntity
=
ParamChecker
.
notNull
(
newEntity
,
"updatedEntity cannot be null"
);
ITypedReferenceableInstance
existInstance
=
validateEntityExists
(
guid
);
ITypedReferenceableInstance
existInstance
=
validateEntityExists
(
guid
);
ITypedReferenceableInstance
newInstance
=
c
onvertToTypedInstance
(
newEntity
,
existInstance
.
getTypeName
());
ITypedReferenceableInstance
newInstance
=
validateAndC
onvertToTypedInstance
(
newEntity
,
existInstance
.
getTypeName
());
((
ReferenceableInstance
)
newInstance
).
replaceWithNewId
(
new
Id
(
guid
,
0
,
newInstance
.
getTypeName
()));
((
ReferenceableInstance
)
newInstance
).
replaceWithNewId
(
new
Id
(
guid
,
0
,
newInstance
.
getTypeName
()));
CreateUpdateEntitiesResult
result
=
repository
.
updatePartial
(
newInstance
);
CreateUpdateEntitiesResult
result
=
repository
.
updatePartial
(
newInstance
);
...
@@ -484,10 +485,11 @@ public class DefaultMetadataService implements MetadataService, ActiveStateChang
...
@@ -484,10 +485,11 @@ public class DefaultMetadataService implements MetadataService, ActiveStateChang
return
result
;
return
result
;
}
}
private
ITypedReferenceableInstance
convertToTypedInstance
(
Referenceable
updatedEntity
,
String
typeName
)
@Override
public
ITypedReferenceableInstance
validateAndConvertToTypedInstance
(
IReferenceableInstance
updatedEntity
,
String
typeName
)
throws
AtlasException
{
throws
AtlasException
{
ClassType
type
=
typeSystem
.
getDataType
(
ClassType
.
class
,
typeName
);
ClassType
type
=
typeSystem
.
getDataType
(
ClassType
.
class
,
typeName
);
ITypedReferenceableInstance
newInstance
=
type
.
createInstance
();
ITypedReferenceableInstance
newInstance
=
type
.
createInstance
(
updatedEntity
.
getId
()
);
for
(
String
attributeName
:
updatedEntity
.
getValuesMap
().
keySet
())
{
for
(
String
attributeName
:
updatedEntity
.
getValuesMap
().
keySet
())
{
AttributeInfo
attributeInfo
=
type
.
fieldMapping
.
fields
.
get
(
attributeName
);
AttributeInfo
attributeInfo
=
type
.
fieldMapping
.
fields
.
get
(
attributeName
);
...
@@ -538,7 +540,7 @@ public class DefaultMetadataService implements MetadataService, ActiveStateChang
...
@@ -538,7 +540,7 @@ public class DefaultMetadataService implements MetadataService, ActiveStateChang
ITypedReferenceableInstance
oldInstance
=
getEntityDefinitionReference
(
typeName
,
uniqueAttributeName
,
attrValue
);
ITypedReferenceableInstance
oldInstance
=
getEntityDefinitionReference
(
typeName
,
uniqueAttributeName
,
attrValue
);
final
ITypedReferenceableInstance
newInstance
=
c
onvertToTypedInstance
(
updatedEntity
,
typeName
);
final
ITypedReferenceableInstance
newInstance
=
validateAndC
onvertToTypedInstance
(
updatedEntity
,
typeName
);
((
ReferenceableInstance
)
newInstance
).
replaceWithNewId
(
oldInstance
.
getId
());
((
ReferenceableInstance
)
newInstance
).
replaceWithNewId
(
oldInstance
.
getId
());
CreateUpdateEntitiesResult
result
=
repository
.
updatePartial
(
newInstance
);
CreateUpdateEntitiesResult
result
=
repository
.
updatePartial
(
newInstance
);
...
...
This diff is collapsed.
Click to expand it.
server-api/src/main/java/org/apache/atlas/services/MetadataService.java
View file @
44df46cf
...
@@ -23,6 +23,7 @@ import org.apache.atlas.AtlasException;
...
@@ -23,6 +23,7 @@ import org.apache.atlas.AtlasException;
import
org.apache.atlas.CreateUpdateEntitiesResult
;
import
org.apache.atlas.CreateUpdateEntitiesResult
;
import
org.apache.atlas.EntityAuditEvent
;
import
org.apache.atlas.EntityAuditEvent
;
import
org.apache.atlas.listener.EntityChangeListener
;
import
org.apache.atlas.listener.EntityChangeListener
;
import
org.apache.atlas.typesystem.IReferenceableInstance
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
import
org.apache.atlas.typesystem.ITypedStruct
;
import
org.apache.atlas.typesystem.ITypedStruct
;
import
org.apache.atlas.typesystem.Referenceable
;
import
org.apache.atlas.typesystem.Referenceable
;
...
@@ -309,4 +310,7 @@ public interface MetadataService {
...
@@ -309,4 +310,7 @@ public interface MetadataService {
* @throws AtlasException
* @throws AtlasException
*/
*/
ITypedReferenceableInstance
[]
deserializeClassInstances
(
String
entityInstanceDefinition
)
throws
AtlasException
;
ITypedReferenceableInstance
[]
deserializeClassInstances
(
String
entityInstanceDefinition
)
throws
AtlasException
;
ITypedReferenceableInstance
validateAndConvertToTypedInstance
(
IReferenceableInstance
updatedEntity
,
String
typeName
)
throws
AtlasException
;
}
}
This diff is collapsed.
Click to expand it.
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