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
4c901bd0
Commit
4c901bd0
authored
6 years ago
by
apoorvnaik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2815: Restoring the deleted audit call
Change-Id: Ia40cab9a258eb7e679975b414c7d6caf9eb6cbb5
parent
54d623c3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
1 deletion
+45
-1
EntityREST.java
...p/src/main/java/org/apache/atlas/web/rest/EntityREST.java
+45
-1
No files found.
webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
View file @
4c901bd0
...
...
@@ -18,8 +18,10 @@
package
org
.
apache
.
atlas
.
web
.
rest
;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.EntityAuditEvent
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.TypeCategory
;
import
org.apache.atlas.model.audit.EntityAuditEventV2
;
import
org.apache.atlas.model.instance.AtlasClassification
;
import
org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo
;
import
org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo
;
...
...
@@ -27,6 +29,8 @@ import org.apache.atlas.model.instance.AtlasEntityHeader;
import
org.apache.atlas.model.instance.ClassificationAssociateRequest
;
import
org.apache.atlas.model.instance.EntityMutationResponse
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef
;
import
org.apache.atlas.repository.audit.EntityAuditRepository
;
import
org.apache.atlas.repository.converters.AtlasInstanceConverter
;
import
org.apache.atlas.repository.store.graph.AtlasEntityStore
;
import
org.apache.atlas.repository.store.graph.v2.AtlasEntityStream
;
import
org.apache.atlas.repository.store.graph.v2.EntityStream
;
...
...
@@ -39,6 +43,7 @@ import org.apache.commons.collections.CollectionUtils;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
javax.inject.Inject
;
...
...
@@ -61,17 +66,24 @@ import java.util.Map;
@Singleton
@Service
public
class
EntityREST
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
EntityREST
.
class
);
private
static
final
Logger
PERF_LOG
=
AtlasPerfTracer
.
getPerfLogger
(
"rest.EntityREST"
);
public
static
final
String
PREFIX_ATTR
=
"attr:"
;
private
final
AtlasTypeRegistry
typeRegistry
;
private
final
AtlasEntityStore
entitiesStore
;
private
final
EntityAuditRepository
auditRepository
;
private
final
AtlasInstanceConverter
instanceConverter
;
@Inject
public
EntityREST
(
AtlasTypeRegistry
typeRegistry
,
AtlasEntityStore
entitiesStore
)
{
public
EntityREST
(
AtlasTypeRegistry
typeRegistry
,
AtlasEntityStore
entitiesStore
,
EntityAuditRepository
auditRepository
,
AtlasInstanceConverter
instanceConverter
)
{
this
.
typeRegistry
=
typeRegistry
;
this
.
entitiesStore
=
entitiesStore
;
this
.
auditRepository
=
auditRepository
;
this
.
instanceConverter
=
instanceConverter
;
}
/**
...
...
@@ -701,6 +713,38 @@ public class EntityREST {
}
}
@GET
@Path
(
"{guid}/audit"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
List
<
EntityAuditEventV2
>
getAuditEvents
(
@PathParam
(
"guid"
)
String
guid
,
@QueryParam
(
"startKey"
)
String
startKey
,
@QueryParam
(
"count"
)
@DefaultValue
(
"100"
)
short
count
)
throws
AtlasBaseException
{
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"EntityREST.getAuditEvents("
+
guid
+
", "
+
startKey
+
", "
+
count
+
")"
);
}
List
events
=
auditRepository
.
listEvents
(
guid
,
startKey
,
count
);
List
<
EntityAuditEventV2
>
ret
=
new
ArrayList
<>();
for
(
Object
event
:
events
)
{
if
(
event
instanceof
EntityAuditEventV2
)
{
ret
.
add
((
EntityAuditEventV2
)
event
);
}
else
if
(
event
instanceof
EntityAuditEvent
)
{
ret
.
add
(
instanceConverter
.
toV2AuditEvent
((
EntityAuditEvent
)
event
));
}
else
{
LOG
.
warn
(
"unknown entity-audit event type {}. Ignored"
,
event
!=
null
?
event
.
getClass
().
getCanonicalName
()
:
"null"
);
}
}
return
ret
;
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
private
AtlasEntityType
ensureEntityType
(
String
typeName
)
throws
AtlasBaseException
{
AtlasEntityType
ret
=
typeRegistry
.
getEntityTypeByName
(
typeName
);
...
...
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