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
e4cc16ac
Commit
e4cc16ac
authored
Feb 17, 2017
by
Sarath Subramaniam
Committed by
Vimal Sharma
Feb 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1565 Create EntityREST endpoints for delete operations
parent
69db4a82
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
108 deletions
+75
-108
release-log.txt
release-log.txt
+1
-0
AtlasEntityStore.java
...apache/atlas/repository/store/graph/AtlasEntityStore.java
+1
-1
EntityREST.java
...p/src/main/java/org/apache/atlas/web/rest/EntityREST.java
+73
-105
TypesREST.java
...pp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
+0
-2
No files found.
release-log.txt
View file @
e4cc16ac
...
@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
...
@@ -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)
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES:
ALL CHANGES:
ATLAS-1565 Create EntityREST endpoints for delete operations (sarathkumarsubramanian via svimal2106)
ATLAS-1547 Added tests for hard delete (mneethiraj)
ATLAS-1547 Added tests for hard delete (mneethiraj)
ATLAS-1546 (ATLAS-1546.3.patch)Hive hook should choose appropriate JAAS config if host uses kerberos ticket-cache (nixonrodrigues via kevalbhat)
ATLAS-1546 (ATLAS-1546.3.patch)Hive hook should choose appropriate JAAS config if host uses kerberos ticket-cache (nixonrodrigues via kevalbhat)
ATLAS-1503 Export/import support to copy data between Atlas instances (ashutoshm via mneethiraj)
ATLAS-1503 Export/import support to copy data between Atlas instances (ashutoshm via mneethiraj)
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java
View file @
e4cc16ac
...
@@ -87,7 +87,7 @@ public interface AtlasEntityStore {
...
@@ -87,7 +87,7 @@ public interface AtlasEntityStore {
EntityMutationResponse
deleteById
(
String
guid
)
throws
AtlasBaseException
;
EntityMutationResponse
deleteById
(
String
guid
)
throws
AtlasBaseException
;
/**
/**
*
@deprecated
*
Deletes an entity using its type and unique attributes
* @param entityType type of the entity
* @param entityType type of the entity
* @param uniqAttributes Attributes that uniquely identify the entity
* @param uniqAttributes Attributes that uniquely identify the entity
* @return EntityMutationResponse details of the updates performed by this call
* @return EntityMutationResponse details of the updates performed by this call
...
...
webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
View file @
e4cc16ac
...
@@ -17,10 +17,8 @@
...
@@ -17,10 +17,8 @@
*/
*/
package
org
.
apache
.
atlas
.
web
.
rest
;
package
org
.
apache
.
atlas
.
web
.
rest
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.CreateUpdateEntitiesResult
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.TypeCategory
;
import
org.apache.atlas.model.TypeCategory
;
import
org.apache.atlas.model.instance.AtlasClassification
;
import
org.apache.atlas.model.instance.AtlasClassification
;
...
@@ -39,15 +37,11 @@ import org.apache.atlas.type.AtlasEntityType;
...
@@ -39,15 +37,11 @@ import org.apache.atlas.type.AtlasEntityType;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.typesystem.IStruct
;
import
org.apache.atlas.typesystem.IStruct
;
import
org.apache.atlas.typesystem.ITypedStruct
;
import
org.apache.atlas.typesystem.ITypedStruct
;
import
org.apache.atlas.typesystem.Referenceable
;
import
org.apache.atlas.web.adapters.AtlasFormatConverter
;
import
org.apache.atlas.web.adapters.AtlasInstanceRestAdapters
;
import
org.apache.atlas.web.adapters.AtlasInstanceRestAdapters
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.atlas.web.util.Servlets
;
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.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.inject.Singleton
;
import
javax.inject.Singleton
;
...
@@ -61,7 +55,6 @@ import java.util.List;
...
@@ -61,7 +55,6 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
static
org
.
apache
.
atlas
.
web
.
adapters
.
AtlasInstanceRestAdapters
.
toAtlasBaseException
;
import
static
org
.
apache
.
atlas
.
web
.
adapters
.
AtlasInstanceRestAdapters
.
toAtlasBaseException
;
import
static
org
.
apache
.
atlas
.
web
.
adapters
.
AtlasInstanceRestAdapters
.
toEntityMutationResponse
;
/**
/**
* REST for a single entity
* REST for a single entity
...
@@ -70,8 +63,6 @@ import static org.apache.atlas.web.adapters.AtlasInstanceRestAdapters.toEntityMu
...
@@ -70,8 +63,6 @@ import static org.apache.atlas.web.adapters.AtlasInstanceRestAdapters.toEntityMu
@Singleton
@Singleton
public
class
EntityREST
{
public
class
EntityREST
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
EntityREST
.
class
);
public
static
final
String
PREFIX_ATTR
=
"attr:"
;
public
static
final
String
PREFIX_ATTR
=
"attr:"
;
private
final
AtlasTypeRegistry
typeRegistry
;
private
final
AtlasTypeRegistry
typeRegistry
;
...
@@ -88,8 +79,7 @@ public class EntityREST {
...
@@ -88,8 +79,7 @@ public class EntityREST {
}
}
/**
/**
* Fetch the complete definition of an entity given its GUID.
* Fetch complete definition of an entity given its GUID.
*
* @param guid GUID for the entity
* @param guid GUID for the entity
* @return AtlasEntity
* @return AtlasEntity
* @throws AtlasBaseException
* @throws AtlasBaseException
...
@@ -103,9 +93,9 @@ public class EntityREST {
...
@@ -103,9 +93,9 @@ public class EntityREST {
}
}
/**
/**
*
Get entity information using entity
type and unique attribute.
*
Fetch complete definition of an entity given its
type and unique attribute.
* @param typeName
* @param typeName
* @return
* @return
AtlasEntityWithExtInfo
* @throws AtlasBaseException
* @throws AtlasBaseException
*/
*/
@GET
@GET
...
@@ -136,29 +126,6 @@ public class EntityREST {
...
@@ -136,29 +126,6 @@ public class EntityREST {
return
entitiesStore
.
createOrUpdate
(
new
AtlasEntityStream
(
entity
),
false
);
return
entitiesStore
.
createOrUpdate
(
new
AtlasEntityStream
(
entity
),
false
);
}
}
/**
* Delete an entity identified by its GUID
*
* @param guid
* @return
*/
@DELETE
@Path
(
"guid/{guid}"
)
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
EntityMutationResponse
deleteByGuid
(
@PathParam
(
"guid"
)
final
String
guid
)
throws
AtlasBaseException
{
if
(
StringUtils
.
isEmpty
(
guid
))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
INSTANCE_GUID_NOT_FOUND
,
guid
);
}
try
{
AtlasClient
.
EntityResult
result
=
metadataService
.
deleteEntities
(
new
ArrayList
<
String
>()
{{
add
(
guid
);
}});
return
toEntityMutationResponse
(
result
);
}
catch
(
AtlasException
e
)
{
throw
toAtlasBaseException
(
e
);
}
}
/*******
/*******
* Entity Partial Update - Allows a subset of attributes to be updated on
* Entity Partial Update - Allows a subset of attributes to be updated on
* an entity which is identified by its type and unique attribute eg: Referenceable.qualifiedName.
* an entity which is identified by its type and unique attribute eg: Referenceable.qualifiedName.
...
@@ -169,8 +136,8 @@ public class EntityREST {
...
@@ -169,8 +136,8 @@ public class EntityREST {
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Path
(
"/uniqueAttribute/type/{typeName}"
)
@Path
(
"/uniqueAttribute/type/{typeName}"
)
public
EntityMutationResponse
partialUpdateByUniqueAttributes
(
@PathParam
(
"typeName"
)
String
typeName
,
public
EntityMutationResponse
partialUpdateByUniqueAttributes
(
@PathParam
(
"typeName"
)
String
typeName
,
@Context
HttpServletRequest
servletRequest
,
@Context
HttpServletRequest
servletRequest
,
AtlasEntity
entity
)
throws
Exception
{
AtlasEntity
entity
)
throws
Exception
{
AtlasEntityType
entityType
=
ensureEntityType
(
typeName
);
AtlasEntityType
entityType
=
ensureEntityType
(
typeName
);
Map
<
String
,
Object
>
uniqueAttributes
=
getAttributes
(
servletRequest
);
Map
<
String
,
Object
>
uniqueAttributes
=
getAttributes
(
servletRequest
);
...
@@ -179,76 +146,39 @@ public class EntityREST {
...
@@ -179,76 +146,39 @@ public class EntityREST {
return
entitiesStore
.
updateByUniqueAttributes
(
entityType
,
uniqueAttributes
,
entity
);
return
entitiesStore
.
updateByUniqueAttributes
(
entityType
,
uniqueAttributes
,
entity
);
}
}
@Deprecated
/**
* Delete an entity identified by its GUID.
* @param guid GUID for the entity
* @return EntityMutationResponse
*/
@DELETE
@DELETE
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Path
(
"guid/{guid}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@Path
(
"/uniqueAttribute/type/{typeName}"
)
public
EntityMutationResponse
deleteByUniqueAttribute
(
@PathParam
(
"typeName"
)
String
typeName
,
@Context
HttpServletRequest
servletRequest
)
throws
Exception
{
AtlasEntityType
entityType
=
ensureEntityType
(
typeName
);
Map
<
String
,
Object
>
attributes
=
getAttributes
(
servletRequest
);
validateUniqueAttribute
(
entityType
,
attributes
);
// legacy API supports only one unique attribute
String
attribute
=
attributes
.
keySet
().
toArray
(
new
String
[
1
])[
0
];
String
value
=
(
String
)
attributes
.
get
(
attribute
);
final
AtlasClient
.
EntityResult
result
=
metadataService
.
deleteEntityByUniqueAttribute
(
typeName
,
attribute
,
value
);
return
toEntityMutationResponse
(
result
);
}
@GET
@Path
(
"/bulk"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasEntitiesWithExtInfo
getByGuids
(
@QueryParam
(
"guid"
)
List
<
String
>
guids
)
throws
AtlasBaseException
{
public
EntityMutationResponse
deleteByGuid
(
@PathParam
(
"guid"
)
final
String
guid
)
throws
AtlasBaseException
{
return
entitiesStore
.
deleteById
(
guid
);
if
(
CollectionUtils
.
isEmpty
(
guids
))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
INSTANCE_GUID_NOT_FOUND
,
guids
);
}
AtlasEntitiesWithExtInfo
entities
=
entitiesStore
.
getByIds
(
guids
);
return
entities
;
}
}
/**
/**
*
Create new entity or update existing entity in Atla
s.
*
Delete an entity identified by its type and unique attribute
s.
*
Existing entity is matched using its unique guid if supplied or by its unique attributes eg: qualifiedName
*
@param typeName - entity type to be deleted
* @param
entiti
es
* @param
servletRequest - request containing unique attributes/valu
es
* @return EntityMutationResponse
* @return EntityMutationResponse
* @throws AtlasBaseException
*/
*/
@POST
@Path
(
"/bulk"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
EntityMutationResponse
createOrUpdate
(
AtlasEntitiesWithExtInfo
entities
)
throws
AtlasBaseException
{
EntityStream
entityStream
=
new
AtlasEntityStream
(
entities
);
return
entitiesStore
.
createOrUpdate
(
entityStream
,
false
);
}
/*******
* Entity Delete
*******/
@DELETE
@DELETE
@Path
(
"/bulk"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
EntityMutationResponse
deleteByGuids
(
@QueryParam
(
"guid"
)
final
List
<
String
>
guids
)
throws
AtlasBaseException
{
@Path
(
"/uniqueAttribute/type/{typeName}"
)
EntityMutationResponse
ret
=
entitiesStore
.
deleteByIds
(
guids
);
public
EntityMutationResponse
deleteByUniqueAttribute
(
@PathParam
(
"typeName"
)
String
typeName
,
@Context
HttpServletRequest
servletRequest
)
throws
AtlasBaseException
{
AtlasEntityType
entityType
=
ensureEntityType
(
typeName
);
Map
<
String
,
Object
>
attributes
=
getAttributes
(
servletRequest
);
return
ret
;
return
entitiesStore
.
deleteByUniqueAttributes
(
entityType
,
attributes
)
;
}
}
/**
/**
* Gets the list of classifications for a given entity represented by a guid.
* Gets the list of classifications for a given entity represented by a guid.
*
* @param guid globally unique identifier for the entity
* @param guid globally unique identifier for the entity
* @return a list of classifications for the given entity guid
* @return a list of classifications for the given entity guid
*/
*/
...
@@ -272,10 +202,8 @@ public class EntityREST {
...
@@ -272,10 +202,8 @@ public class EntityREST {
}
}
}
}
/**
/**
* Gets the list of classifications for a given entity represented by a guid.
* Gets the list of classifications for a given entity represented by a guid.
*
* @param guid globally unique identifier for the entity
* @param guid globally unique identifier for the entity
* @return a list of classifications for the given entity guid
* @return a list of classifications for the given entity guid
*/
*/
...
@@ -307,12 +235,7 @@ public class EntityREST {
...
@@ -307,12 +235,7 @@ public class EntityREST {
}
}
/**
/**
* Classification management
*/
/**
* Adds classifications to an existing entity represented by a guid.
* Adds classifications to an existing entity represented by a guid.
*
* @param guid globally unique identifier for the entity
* @param guid globally unique identifier for the entity
*/
*/
@POST
@POST
...
@@ -340,7 +263,6 @@ public class EntityREST {
...
@@ -340,7 +263,6 @@ public class EntityREST {
/**
/**
* Update classification(s) for an entity represented by a guid.
* Update classification(s) for an entity represented by a guid.
* Classifications are identified by their guid or name
* Classifications are identified by their guid or name
*
* @param guid globally unique identifier for the entity
* @param guid globally unique identifier for the entity
*/
*/
@PUT
@PUT
...
@@ -357,7 +279,6 @@ public class EntityREST {
...
@@ -357,7 +279,6 @@ public class EntityREST {
/**
/**
* Deletes a given classification from an existing entity represented by a guid.
* Deletes a given classification from an existing entity represented by a guid.
*
* @param guid globally unique identifier for the entity
* @param guid globally unique identifier for the entity
* @param typeName name of the trait
* @param typeName name of the trait
*/
*/
...
@@ -381,9 +302,56 @@ public class EntityREST {
...
@@ -381,9 +302,56 @@ public class EntityREST {
}
}
}
}
/******************************************************************/
/** Bulk API operations **/
/******************************************************************/
/**
* Bulk API to retrieve list of entities identified by its GUIDs.
*/
@GET
@Path
(
"/bulk"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasEntitiesWithExtInfo
getByGuids
(
@QueryParam
(
"guid"
)
List
<
String
>
guids
)
throws
AtlasBaseException
{
if
(
CollectionUtils
.
isEmpty
(
guids
))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
INSTANCE_GUID_NOT_FOUND
,
guids
);
}
AtlasEntitiesWithExtInfo
entities
=
entitiesStore
.
getByIds
(
guids
);
return
entities
;
}
/**
* Bulk API to create new entities or update existing entities in Atlas.
* Existing entity is matched using its unique guid if supplied or by its unique attributes eg: qualifiedName
*/
@POST
@Path
(
"/bulk"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
EntityMutationResponse
createOrUpdate
(
AtlasEntitiesWithExtInfo
entities
)
throws
AtlasBaseException
{
EntityStream
entityStream
=
new
AtlasEntityStream
(
entities
);
return
entitiesStore
.
createOrUpdate
(
entityStream
,
false
);
}
/**
* Bulk API to delete list of entities identified by its GUIDs
*/
@DELETE
@Path
(
"/bulk"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
EntityMutationResponse
deleteByGuids
(
@QueryParam
(
"guid"
)
final
List
<
String
>
guids
)
throws
AtlasBaseException
{
return
entitiesStore
.
deleteByIds
(
guids
);
}
/**
/**
* Bulk API to associate a tag to multiple entities
* Bulk API to associate a tag to multiple entities
*
*/
*/
@POST
@POST
@Path
(
"/bulk/classification"
)
@Path
(
"/bulk/classification"
)
...
@@ -412,7 +380,6 @@ public class EntityREST {
...
@@ -412,7 +380,6 @@ public class EntityREST {
}
}
}
}
private
AtlasEntityType
ensureEntityType
(
String
typeName
)
throws
AtlasBaseException
{
private
AtlasEntityType
ensureEntityType
(
String
typeName
)
throws
AtlasBaseException
{
AtlasEntityType
ret
=
typeRegistry
.
getEntityTypeByName
(
typeName
);
AtlasEntityType
ret
=
typeRegistry
.
getEntityTypeByName
(
typeName
);
...
@@ -470,4 +437,4 @@ public class EntityREST {
...
@@ -470,4 +437,4 @@ public class EntityREST {
}
}
}
}
}
}
}
}
\ No newline at end of file
webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
View file @
e4cc16ac
...
@@ -20,10 +20,8 @@ package org.apache.atlas.web.rest;
...
@@ -20,10 +20,8 @@ package org.apache.atlas.web.rest;
import
com.google.inject.Inject
;
import
com.google.inject.Inject
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.SearchFilter
;
import
org.apache.atlas.model.SearchFilter
;
import
org.apache.atlas.model.TypeCategory
;
import
org.apache.atlas.model.typedef.AtlasBaseTypeDef
;
import
org.apache.atlas.model.typedef.AtlasBaseTypeDef
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef.AtlasClassificationDefs
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
...
...
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