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
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
105 deletions
+71
-105
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
+69
-102
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
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES:
ATLAS-1565 Create EntityREST endpoints for delete operations (sarathkumarsubramanian via svimal2106)
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-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 {
EntityMutationResponse
deleteById
(
String
guid
)
throws
AtlasBaseException
;
/**
*
@deprecated
*
Deletes an entity using its type and unique attributes
* @param entityType type of the entity
* @param uniqAttributes Attributes that uniquely identify the entity
* @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 @@
*/
package
org
.
apache
.
atlas
.
web
.
rest
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.CreateUpdateEntitiesResult
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.TypeCategory
;
import
org.apache.atlas.model.instance.AtlasClassification
;
...
...
@@ -39,15 +37,11 @@ import org.apache.atlas.type.AtlasEntityType;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.typesystem.IStruct
;
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.util.Servlets
;
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
javax.inject.Inject
;
import
javax.inject.Singleton
;
...
...
@@ -61,7 +55,6 @@ import java.util.List;
import
java.util.Map
;
import
static
org
.
apache
.
atlas
.
web
.
adapters
.
AtlasInstanceRestAdapters
.
toAtlasBaseException
;
import
static
org
.
apache
.
atlas
.
web
.
adapters
.
AtlasInstanceRestAdapters
.
toEntityMutationResponse
;
/**
* REST for a single entity
...
...
@@ -70,8 +63,6 @@ import static org.apache.atlas.web.adapters.AtlasInstanceRestAdapters.toEntityMu
@Singleton
public
class
EntityREST
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
EntityREST
.
class
);
public
static
final
String
PREFIX_ATTR
=
"attr:"
;
private
final
AtlasTypeRegistry
typeRegistry
;
...
...
@@ -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
* @return AtlasEntity
* @throws AtlasBaseException
...
...
@@ -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
* @return
* @return
AtlasEntityWithExtInfo
* @throws AtlasBaseException
*/
@GET
...
...
@@ -136,29 +126,6 @@ public class EntityREST {
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
* an entity which is identified by its type and unique attribute eg: Referenceable.qualifiedName.
...
...
@@ -179,76 +146,39 @@ public class EntityREST {
return
entitiesStore
.
updateByUniqueAttributes
(
entityType
,
uniqueAttributes
,
entity
);
}
@Deprecated
/**
* Delete an entity identified by its GUID.
* @param guid GUID for the entity
* @return EntityMutationResponse
*/
@DELETE
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@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
)
@Path
(
"guid/{guid}"
)
@Consumes
({
Servlets
.
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
})
@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
;
public
EntityMutationResponse
deleteByGuid
(
@PathParam
(
"guid"
)
final
String
guid
)
throws
AtlasBaseException
{
return
entitiesStore
.
deleteById
(
guid
);
}
/**
*
Create new entity or update existing entity in Atla
s.
*
Existing entity is matched using its unique guid if supplied or by its unique attributes eg: qualifiedName
* @param
entiti
es
*
Delete an entity identified by its type and unique attribute
s.
*
@param typeName - entity type to be deleted
* @param
servletRequest - request containing unique attributes/valu
es
* @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
@Path
(
"/bulk"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
EntityMutationResponse
deleteByGuids
(
@QueryParam
(
"guid"
)
final
List
<
String
>
guids
)
throws
AtlasBaseException
{
EntityMutationResponse
ret
=
entitiesStore
.
deleteByIds
(
guids
);
@Path
(
"/uniqueAttribute/type/{typeName}"
)
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.
*
* @param guid globally unique identifier for the entity
* @return a list of classifications for the given entity guid
*/
...
...
@@ -272,10 +202,8 @@ public class EntityREST {
}
}
/**
* Gets the list of classifications for a given entity represented by a guid.
*
* @param guid globally unique identifier for the entity
* @return a list of classifications for the given entity guid
*/
...
...
@@ -307,12 +235,7 @@ public class EntityREST {
}
/**
* Classification management
*/
/**
* Adds classifications to an existing entity represented by a guid.
*
* @param guid globally unique identifier for the entity
*/
@POST
...
...
@@ -340,7 +263,6 @@ public class EntityREST {
/**
* Update classification(s) for an entity represented by a guid.
* Classifications are identified by their guid or name
*
* @param guid globally unique identifier for the entity
*/
@PUT
...
...
@@ -357,7 +279,6 @@ public class EntityREST {
/**
* Deletes a given classification from an existing entity represented by a guid.
*
* @param guid globally unique identifier for the entity
* @param typeName name of the trait
*/
...
...
@@ -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
*
*/
@POST
@Path
(
"/bulk/classification"
)
...
...
@@ -412,7 +380,6 @@ public class EntityREST {
}
}
private
AtlasEntityType
ensureEntityType
(
String
typeName
)
throws
AtlasBaseException
{
AtlasEntityType
ret
=
typeRegistry
.
getEntityTypeByName
(
typeName
);
...
...
webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
View file @
e4cc16ac
...
...
@@ -20,10 +20,8 @@ package org.apache.atlas.web.rest;
import
com.google.inject.Inject
;
import
org.apache.atlas.exception.AtlasBaseException
;
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.AtlasClassificationDef
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef.AtlasClassificationDefs
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef
;
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