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
5ebb1690
Commit
5ebb1690
authored
Nov 28, 2018
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2982: import fails to create classification-def
parent
18350777
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
20 deletions
+27
-20
AtlasAuthorizationUtils.java
...a/org/apache/atlas/authorize/AtlasAuthorizationUtils.java
+3
-3
ImportService.java
...ava/org/apache/atlas/repository/impexp/ImportService.java
+3
-0
AtlasEntityStoreV2.java
...e/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java
+5
-6
EntityGraphMapper.java
...he/atlas/repository/store/graph/v2/EntityGraphMapper.java
+5
-5
EntityMutationContext.java
...tlas/repository/store/graph/v2/EntityMutationContext.java
+0
-4
IDBasedEntityResolver.java
...tlas/repository/store/graph/v2/IDBasedEntityResolver.java
+3
-2
RequestContext.java
...er-api/src/main/java/org/apache/atlas/RequestContext.java
+8
-0
No files found.
authorization/src/main/java/org/apache/atlas/authorize/AtlasAuthorizationUtils.java
View file @
5ebb1690
...
...
@@ -111,7 +111,7 @@ public class AtlasAuthorizationUtils {
boolean
ret
=
false
;
String
userName
=
getCurrentUserName
();
if
(
StringUtils
.
isNotEmpty
(
userName
))
{
if
(
StringUtils
.
isNotEmpty
(
userName
)
&&
!
RequestContext
.
get
().
isImportInProgress
()
)
{
try
{
AtlasAuthorizer
authorizer
=
AtlasAuthorizerFactory
.
getAtlasAuthorizer
();
...
...
@@ -132,7 +132,7 @@ public class AtlasAuthorizationUtils {
boolean
ret
=
false
;
String
userName
=
getCurrentUserName
();
if
(
StringUtils
.
isNotEmpty
(
userName
))
{
if
(
StringUtils
.
isNotEmpty
(
userName
)
&&
!
RequestContext
.
get
().
isImportInProgress
()
)
{
try
{
AtlasAuthorizer
authorizer
=
AtlasAuthorizerFactory
.
getAtlasAuthorizer
();
...
...
@@ -153,7 +153,7 @@ public class AtlasAuthorizationUtils {
boolean
ret
=
false
;
String
userName
=
getCurrentUserName
();
if
(
StringUtils
.
isNotEmpty
(
userName
))
{
if
(
StringUtils
.
isNotEmpty
(
userName
)
&&
!
RequestContext
.
get
().
isImportInProgress
()
)
{
try
{
AtlasAuthorizer
authorizer
=
AtlasAuthorizerFactory
.
getAtlasAuthorizer
();
...
...
repository/src/main/java/org/apache/atlas/repository/impexp/ImportService.java
View file @
5ebb1690
...
...
@@ -19,6 +19,7 @@ package org.apache.atlas.repository.impexp;
import
com.google.common.annotations.VisibleForTesting
;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.RequestContext
;
import
org.apache.atlas.entitytransform.BaseEntityHandler
;
import
org.apache.atlas.entitytransform.TransformerContext
;
import
org.apache.atlas.exception.AtlasBaseException
;
...
...
@@ -79,6 +80,8 @@ public class ImportService {
public
AtlasImportResult
run
(
ZipSource
source
,
AtlasImportRequest
request
,
String
userName
,
String
hostName
,
String
requestingIP
)
throws
AtlasBaseException
{
RequestContext
.
get
().
setImportInProgress
(
true
);
if
(
request
==
null
)
{
request
=
new
AtlasImportRequest
();
}
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java
View file @
5ebb1690
...
...
@@ -672,11 +672,10 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore {
}
try
{
final
boolean
isImport
=
entityStream
instanceof
EntityImportStream
;
final
EntityMutationContext
context
=
preCreateOrUpdate
(
entityStream
,
entityGraphMapper
,
isPartialUpdate
);
// Check if authorized to create entities
if
(!
isImport
&&
CollectionUtils
.
isNotEmpty
(
context
.
getCreatedEntities
()
))
{
if
(!
RequestContext
.
get
().
isImportInProgress
(
))
{
for
(
AtlasEntity
entity
:
context
.
getCreatedEntities
())
{
AtlasAuthorizationUtils
.
verifyAccess
(
new
AtlasEntityAccessRequest
(
typeRegistry
,
AtlasPrivilege
.
ENTITY_CREATE
,
new
AtlasEntityHeader
(
entity
)),
"create entity: type="
,
entity
.
getTypeName
());
...
...
@@ -710,7 +709,7 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore {
}
// Check if authorized to update entities
if
(!
isImport
)
{
if
(!
RequestContext
.
get
().
isImportInProgress
()
)
{
for
(
AtlasEntity
entity
:
context
.
getUpdatedEntities
())
{
AtlasAuthorizationUtils
.
verifyAccess
(
new
AtlasEntityAccessRequest
(
typeRegistry
,
AtlasPrivilege
.
ENTITY_UPDATE
,
new
AtlasEntityHeader
(
entity
)),
"update entity: type="
,
entity
.
getTypeName
());
...
...
@@ -723,7 +722,7 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore {
ret
.
setGuidAssignments
(
context
.
getGuidAssignments
());
// Notify the change listeners
entityChangeNotifier
.
onEntitiesMutated
(
ret
,
isImport
);
entityChangeNotifier
.
onEntitiesMutated
(
ret
,
RequestContext
.
get
().
isImportInProgress
()
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== createOrUpdate()"
);
...
...
@@ -772,7 +771,7 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore {
//Create vertices which do not exist in the repository
if
(
(
entityStream
instanceof
EntityImportStream
)
&&
AtlasTypeUtil
.
isAssignedGuid
(
entity
.
getGuid
()))
{
if
(
RequestContext
.
get
().
isImportInProgress
(
)
&&
AtlasTypeUtil
.
isAssignedGuid
(
entity
.
getGuid
()))
{
vertex
=
entityGraphMapper
.
createVertexWithGuid
(
entity
,
entity
.
getGuid
());
}
else
{
vertex
=
entityGraphMapper
.
createVertex
(
entity
);
...
...
@@ -792,7 +791,7 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore {
}
// during import, update the system attributes
if
(
entityStream
instanceof
EntityImportStream
)
{
if
(
RequestContext
.
get
().
isImportInProgress
()
)
{
entityGraphMapper
.
updateSystemAttributes
(
vertex
,
entity
);
}
}
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
View file @
5ebb1690
...
...
@@ -416,7 +416,7 @@ public class EntityGraphMapper {
AtlasEdge
currentEdge
;
// if relationshipGuid is assigned in AtlasRelatedObjectId use it to fetch existing AtlasEdge
if
(
StringUtils
.
isNotEmpty
(
relationshipGuid
)
&&
!
context
.
isImport
())
{
if
(
StringUtils
.
isNotEmpty
(
relationshipGuid
)
&&
!
RequestContext
.
get
().
isImportInProgress
())
{
currentEdge
=
graphHelper
.
getEdgeForGUID
(
relationshipGuid
);
}
else
{
currentEdge
=
graphHelper
.
getEdgeForLabel
(
ctx
.
getReferringVertex
(),
edgeLabel
,
edgeDirection
);
...
...
@@ -611,7 +611,7 @@ public class EntityGraphMapper {
}
private
void
updateRelationshipGuidForImport
(
EntityMutationContext
context
,
String
inverseAttributeName
,
AtlasVertex
inverseVertex
,
AtlasEdge
edge
)
throws
AtlasBaseException
{
if
(!
context
.
isImport
())
{
if
(!
RequestContext
.
get
().
isImportInProgress
())
{
return
;
}
...
...
@@ -795,7 +795,7 @@ public class EntityGraphMapper {
}
if
(
attributeVertex
==
null
)
{
if
(
context
.
isImport
())
{
if
(
RequestContext
.
get
().
isImportInProgress
())
{
return
null
;
}
...
...
@@ -836,7 +836,7 @@ public class EntityGraphMapper {
ret
=
getOrCreateRelationship
(
fromVertex
,
toVertex
,
relationshipName
,
relationshipAttributes
);
// for import use the relationship guid provided
if
(
context
.
isImport
())
{
if
(
RequestContext
.
get
().
isImportInProgress
())
{
String
relationshipGuid
=
getRelationshipGuid
(
ctx
.
getValue
());
if
(!
StringUtils
.
isEmpty
(
relationshipGuid
))
{
...
...
@@ -1384,7 +1384,7 @@ public class EntityGraphMapper {
}
if
(
propagateTags
==
null
)
{
if
(
context
.
isImport
())
{
if
(
RequestContext
.
get
().
isImportInProgress
())
{
propagateTags
=
false
;
classification
.
setPropagate
(
propagateTags
);
}
else
{
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityMutationContext.java
View file @
5ebb1690
...
...
@@ -87,10 +87,6 @@ public class EntityMutationContext {
public
AtlasVertex
getVertex
(
String
guid
)
{
return
entityVsVertex
.
get
(
guid
);
}
public
boolean
isImport
()
{
return
(
context
!=
null
)
&&
context
.
getEntityStream
()
instanceof
EntityImportStream
;
}
@Override
public
boolean
equals
(
final
Object
o
)
{
if
(
this
==
o
)
return
true
;
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/IDBasedEntityResolver.java
View file @
5ebb1690
...
...
@@ -18,6 +18,7 @@
package
org
.
apache
.
atlas
.
repository
.
store
.
graph
.
v2
;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.RequestContext
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.TypeCategory
;
import
org.apache.atlas.model.instance.AtlasEntity
;
...
...
@@ -51,7 +52,7 @@ public class IDBasedEntityResolver implements EntityResolver {
boolean
isAssignedGuid
=
AtlasTypeUtil
.
isAssignedGuid
(
guid
);
AtlasVertex
vertex
=
isAssignedGuid
?
AtlasGraphUtilsV2
.
findByGuid
(
guid
)
:
null
;
if
(
vertex
==
null
&&
!
(
entityStream
instanceof
EntityImportStream
))
{
// if not found in the store, look if the entity is present in the stream
if
(
vertex
==
null
&&
!
RequestContext
.
get
().
isImportInProgress
(
))
{
// if not found in the store, look if the entity is present in the stream
AtlasEntity
entity
=
entityStream
.
getByGuid
(
guid
);
if
(
entity
!=
null
)
{
// look for the entity in the store using unique-attributes
...
...
@@ -70,7 +71,7 @@ public class IDBasedEntityResolver implements EntityResolver {
if
(
vertex
!=
null
)
{
context
.
addResolvedGuid
(
guid
,
vertex
);
}
else
{
if
(
isAssignedGuid
&&
!
(
entityStream
instanceof
EntityImportStream
))
{
if
(
isAssignedGuid
&&
!
RequestContext
.
get
().
isImportInProgress
(
))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
REFERENCED_ENTITY_NOT_FOUND
,
guid
);
}
else
{
context
.
addLocalGuidReference
(
guid
);
...
...
server-api/src/main/java/org/apache/atlas/RequestContext.java
View file @
5ebb1690
...
...
@@ -50,6 +50,7 @@ public class RequestContext {
private
DeleteType
deleteType
=
DeleteType
.
DEFAULT
;
private
int
maxAttempts
=
1
;
private
int
attemptCount
=
1
;
private
boolean
isImportInProgress
=
false
;
private
RequestContext
()
{
...
...
@@ -145,6 +146,13 @@ public class RequestContext {
this
.
attemptCount
=
attemptCount
;
}
public
boolean
isImportInProgress
()
{
return
isImportInProgress
;
}
public
void
setImportInProgress
(
boolean
importInProgress
)
{
isImportInProgress
=
importInProgress
;
}
public
void
recordEntityUpdate
(
AtlasObjectId
entity
)
{
if
(
entity
!=
null
&&
entity
.
getGuid
()
!=
null
)
{
...
...
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