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
d661964c
Commit
d661964c
authored
Jun 03, 2016
by
Suma Shivaprasad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-858 Unable to delete terms via API which are 3 or more levels deep(jspeidel via sumasai)
parent
9e23fdc1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
33 deletions
+68
-33
release-log.txt
release-log.txt
+1
-0
pom.xml
webapp/pom.xml
+6
-0
BaseService.java
...main/java/org/apache/atlas/web/resources/BaseService.java
+8
-3
EntityService.java
...in/java/org/apache/atlas/web/resources/EntityService.java
+4
-5
TaxonomyService.java
.../java/org/apache/atlas/web/resources/TaxonomyService.java
+49
-25
TaxonomyServiceTest.java
...a/org/apache/atlas/web/resources/TaxonomyServiceTest.java
+0
-0
No files found.
release-log.txt
View file @
d661964c
...
@@ -22,6 +22,7 @@ ATLAS-409 Atlas will not import avro tables with schema read from a file (dosset
...
@@ -22,6 +22,7 @@ ATLAS-409 Atlas will not import avro tables with schema read from a file (dosset
ATLAS-379 Create sqoop and falcon metadata addons (venkatnrangan,bvellanki,sowmyaramesh via shwethags)
ATLAS-379 Create sqoop and falcon metadata addons (venkatnrangan,bvellanki,sowmyaramesh via shwethags)
ALL CHANGES:
ALL CHANGES:
ATLAS-858 Unable to delete terms via API which are 3 or more levels deep (jspeidel via sumasai)
ATLAS-848 Atlas UI: Search term box in left navigation is not auto refresh.(Kalyanikashikar via sumasai)
ATLAS-848 Atlas UI: Search term box in left navigation is not auto refresh.(Kalyanikashikar via sumasai)
ATLAS-793 Business Catalog Delete (jspeidel via yhemanth)
ATLAS-793 Business Catalog Delete (jspeidel via yhemanth)
ATLAS-846 Atlas UI : Add Pagination to Tags and Terms tabs of asset detailes page (kevalbhatt18 via yhemanth)
ATLAS-846 Atlas UI : Add Pagination to Tags and Terms tabs of asset detailes page (kevalbhatt18 via yhemanth)
...
...
webapp/pom.xml
View file @
d661964c
...
@@ -297,6 +297,12 @@
...
@@ -297,6 +297,12 @@
<artifactId>
atlas-dashboardv2
</artifactId>
<artifactId>
atlas-dashboardv2
</artifactId>
<type>
war
</type>
<type>
war
</type>
</dependency>
</dependency>
<dependency>
<groupId>
org.easymock
</groupId>
<artifactId>
easymock
</artifactId>
<version>
3.4
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
webapp/src/main/java/org/apache/atlas/web/resources/BaseService.java
View file @
d661964c
...
@@ -40,6 +40,7 @@ import java.util.Map;
...
@@ -40,6 +40,7 @@ import java.util.Map;
public
abstract
class
BaseService
{
public
abstract
class
BaseService
{
private
static
final
Gson
gson
=
new
Gson
();
private
static
final
Gson
gson
=
new
Gson
();
private
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
getClass
());
private
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
getClass
());
private
final
static
JsonSerializer
serializer
=
new
JsonSerializer
();
protected
Result
getResource
(
ResourceProvider
provider
,
Request
request
)
protected
Result
getResource
(
ResourceProvider
provider
,
Request
request
)
throws
ResourceNotFoundException
{
throws
ResourceNotFoundException
{
...
@@ -118,16 +119,20 @@ public abstract class BaseService {
...
@@ -118,16 +119,20 @@ public abstract class BaseService {
}
}
}
}
pr
ivate
RuntimeException
wrapRuntimeException
(
RuntimeException
e
)
{
pr
otected
JsonSerializer
getSerializer
(
)
{
return
e
instanceof
CatalogRuntimeException
?
e
:
new
CatalogRuntimeException
(
e
)
;
return
serializer
;
}
}
//todo: abstract via AtlasTypeSystem
//todo: abstract via AtlasTypeSystem
// ensure that the thread wasn't re-pooled with an existing transaction
// ensure that the thread wasn't re-pooled with an existing transaction
pr
ivate
void
initializeGraphTransaction
()
{
pr
otected
void
initializeGraphTransaction
()
{
TitanGraphProvider
.
getGraphInstance
().
rollback
();
TitanGraphProvider
.
getGraphInstance
().
rollback
();
}
}
private
RuntimeException
wrapRuntimeException
(
RuntimeException
e
)
{
return
e
instanceof
CatalogRuntimeException
?
e
:
new
CatalogRuntimeException
(
e
);
}
@XmlRootElement
@XmlRootElement
// the name of this class is used as the collection name in the returned json when returning a collection
// the name of this class is used as the collection name in the returned json when returning a collection
public
static
class
Results
{
public
static
class
Results
{
...
...
webapp/src/main/java/org/apache/atlas/web/resources/EntityService.java
View file @
d661964c
...
@@ -38,7 +38,6 @@ public class EntityService extends BaseService {
...
@@ -38,7 +38,6 @@ public class EntityService extends BaseService {
private
final
EntityResourceProvider
entityResourceProvider
;
private
final
EntityResourceProvider
entityResourceProvider
;
private
final
EntityTagResourceProvider
entityTagResourceProvider
;
private
final
EntityTagResourceProvider
entityTagResourceProvider
;
private
static
JsonSerializer
m_serializer
=
new
JsonSerializer
();
@Inject
@Inject
public
EntityService
(
MetadataService
metadataService
)
{
public
EntityService
(
MetadataService
metadataService
)
{
...
@@ -55,7 +54,7 @@ public class EntityService extends BaseService {
...
@@ -55,7 +54,7 @@ public class EntityService extends BaseService {
BaseRequest
request
=
new
CollectionRequest
(
Collections
.<
String
,
Object
>
emptyMap
(),
queryString
);
BaseRequest
request
=
new
CollectionRequest
(
Collections
.<
String
,
Object
>
emptyMap
(),
queryString
);
Result
result
=
getResources
(
entityResourceProvider
,
request
);
Result
result
=
getResources
(
entityResourceProvider
,
request
);
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
m_serializer
.
serialize
(
result
,
ui
)).
build
();
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
()
.
serialize
(
result
,
ui
)).
build
();
}
}
@GET
@GET
...
@@ -68,7 +67,7 @@ public class EntityService extends BaseService {
...
@@ -68,7 +67,7 @@ public class EntityService extends BaseService {
BaseRequest
request
=
new
InstanceRequest
(
Collections
.<
String
,
Object
>
singletonMap
(
"id"
,
entityId
));
BaseRequest
request
=
new
InstanceRequest
(
Collections
.<
String
,
Object
>
singletonMap
(
"id"
,
entityId
));
Result
result
=
getResource
(
entityResourceProvider
,
request
);
Result
result
=
getResource
(
entityResourceProvider
,
request
);
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
m_serializer
.
serialize
(
result
,
ui
)).
build
();
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
()
.
serialize
(
result
,
ui
)).
build
();
}
}
@GET
@GET
...
@@ -84,7 +83,7 @@ public class EntityService extends BaseService {
...
@@ -84,7 +83,7 @@ public class EntityService extends BaseService {
properties
.
put
(
"name"
,
tagName
);
properties
.
put
(
"name"
,
tagName
);
Result
result
=
getResource
(
entityTagResourceProvider
,
new
InstanceRequest
(
properties
));
Result
result
=
getResource
(
entityTagResourceProvider
,
new
InstanceRequest
(
properties
));
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
m_serializer
.
serialize
(
result
,
ui
)).
build
();
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
()
.
serialize
(
result
,
ui
)).
build
();
}
}
@GET
@GET
...
@@ -98,7 +97,7 @@ public class EntityService extends BaseService {
...
@@ -98,7 +97,7 @@ public class EntityService extends BaseService {
decode
(
getQueryString
(
ui
)));
decode
(
getQueryString
(
ui
)));
Result
result
=
getResources
(
entityTagResourceProvider
,
request
);
Result
result
=
getResources
(
entityTagResourceProvider
,
request
);
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
m_serializer
.
serialize
(
result
,
ui
)).
build
();
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
()
.
serialize
(
result
,
ui
)).
build
();
}
}
@POST
@POST
...
...
webapp/src/main/java/org/apache/atlas/web/resources/TaxonomyService.java
View file @
d661964c
...
@@ -41,15 +41,14 @@ import java.util.Map;
...
@@ -41,15 +41,14 @@ import java.util.Map;
@Singleton
@Singleton
public
class
TaxonomyService
extends
BaseService
{
public
class
TaxonomyService
extends
BaseService
{
private
final
TaxonomyResourceProvider
taxonomyResourceProvider
;
private
ResourceProvider
taxonomyResourceProvider
;
private
static
TermResourceProvider
termResourceProvider
;
private
ResourceProvider
termResourceProvider
;
private
static
JsonSerializer
serializer
=
new
JsonSerializer
();
@Inject
@Inject
public
Taxonomy
Service
(
MetadataService
metadataService
)
{
public
void
setMetadata
Service
(
MetadataService
metadataService
)
{
DefaultTypeSystem
typeSystem
=
new
DefaultTypeSystem
(
metadataService
);
DefaultTypeSystem
typeSystem
=
new
DefaultTypeSystem
(
metadataService
);
taxonomyResourceProvider
=
new
TaxonomyResourceProvider
(
typeSystem
);
taxonomyResourceProvider
=
create
TaxonomyResourceProvider
(
typeSystem
);
termResourceProvider
=
new
TermResourceProvider
(
typeSystem
);
termResourceProvider
=
create
TermResourceProvider
(
typeSystem
);
}
}
@GET
@GET
...
@@ -62,7 +61,7 @@ public class TaxonomyService extends BaseService {
...
@@ -62,7 +61,7 @@ public class TaxonomyService extends BaseService {
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
properties
.
put
(
"name"
,
taxonomyName
);
properties
.
put
(
"name"
,
taxonomyName
);
Result
result
=
getResource
(
taxonomyResourceProvider
,
new
InstanceRequest
(
properties
));
Result
result
=
getResource
(
taxonomyResourceProvider
,
new
InstanceRequest
(
properties
));
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
serializer
.
serialize
(
result
,
ui
)).
build
();
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
()
.
serialize
(
result
,
ui
)).
build
();
}
}
@GET
@GET
...
@@ -71,7 +70,7 @@ public class TaxonomyService extends BaseService {
...
@@ -71,7 +70,7 @@ public class TaxonomyService extends BaseService {
String
queryString
=
decode
(
getQueryString
(
ui
));
String
queryString
=
decode
(
getQueryString
(
ui
));
Request
request
=
new
CollectionRequest
(
Collections
.<
String
,
Object
>
emptyMap
(),
queryString
);
Request
request
=
new
CollectionRequest
(
Collections
.<
String
,
Object
>
emptyMap
(),
queryString
);
Result
result
=
getResources
(
taxonomyResourceProvider
,
request
);
Result
result
=
getResources
(
taxonomyResourceProvider
,
request
);
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
serializer
.
serialize
(
result
,
ui
)).
build
();
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
()
.
serialize
(
result
,
ui
)).
build
();
}
}
@POST
@POST
...
@@ -120,7 +119,7 @@ public class TaxonomyService extends BaseService {
...
@@ -120,7 +119,7 @@ public class TaxonomyService extends BaseService {
properties
.
put
(
"termPath"
,
termPath
);
properties
.
put
(
"termPath"
,
termPath
);
Result
result
=
getResource
(
termResourceProvider
,
new
InstanceRequest
(
properties
));
Result
result
=
getResource
(
termResourceProvider
,
new
InstanceRequest
(
properties
));
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
serializer
.
serialize
(
result
,
ui
)).
build
();
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
()
.
serialize
(
result
,
ui
)).
build
();
}
}
@GET
@GET
...
@@ -136,7 +135,7 @@ public class TaxonomyService extends BaseService {
...
@@ -136,7 +135,7 @@ public class TaxonomyService extends BaseService {
Collections
.<
String
,
Object
>
singletonMap
(
"termPath"
,
termPath
),
queryString
);
Collections
.<
String
,
Object
>
singletonMap
(
"termPath"
,
termPath
),
queryString
);
Result
result
=
getResources
(
termResourceProvider
,
request
);
Result
result
=
getResources
(
termResourceProvider
,
request
);
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
serializer
.
serialize
(
result
,
ui
)).
build
();
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
()
.
serialize
(
result
,
ui
)).
build
();
}
}
@GET
@GET
...
@@ -149,11 +148,6 @@ public class TaxonomyService extends BaseService {
...
@@ -149,11 +148,6 @@ public class TaxonomyService extends BaseService {
@PathParam
(
"remainder"
)
String
remainder
)
throws
CatalogException
{
@PathParam
(
"remainder"
)
String
remainder
)
throws
CatalogException
{
Result
result
;
Result
result
;
List
<
PathSegment
>
pathSegments
=
ui
.
getPathSegments
();
int
lastIndex
=
pathSegments
.
size
()
-
1
;
String
lastSegment
=
pathSegments
.
get
(
lastIndex
).
getPath
();
String
termName
=
String
.
format
(
"%s%s"
,
rootTerm
,
String
termName
=
String
.
format
(
"%s%s"
,
rootTerm
,
remainder
.
replaceAll
(
"/?terms/?([.]*)"
,
"$1."
));
remainder
.
replaceAll
(
"/?terms/?([.]*)"
,
"$1."
));
String
queryString
=
decode
(
getQueryString
(
ui
));
String
queryString
=
decode
(
getQueryString
(
ui
));
...
@@ -161,13 +155,17 @@ public class TaxonomyService extends BaseService {
...
@@ -161,13 +155,17 @@ public class TaxonomyService extends BaseService {
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
properties
.
put
(
"termPath"
,
termPath
);
properties
.
put
(
"termPath"
,
termPath
);
List
<
PathSegment
>
pathSegments
=
ui
.
getPathSegments
();
int
lastIndex
=
pathSegments
.
size
()
-
1
;
String
lastSegment
=
pathSegments
.
get
(
lastIndex
).
getPath
();
if
(
lastSegment
.
equals
(
"terms"
)
||
(
lastSegment
.
isEmpty
()
&&
pathSegments
.
get
(
lastIndex
-
1
).
getPath
().
equals
(
"terms"
)))
{
if
(
lastSegment
.
equals
(
"terms"
)
||
(
lastSegment
.
isEmpty
()
&&
pathSegments
.
get
(
lastIndex
-
1
).
getPath
().
equals
(
"terms"
)))
{
result
=
getResources
(
termResourceProvider
,
new
CollectionRequest
(
properties
,
queryString
));
result
=
getResources
(
termResourceProvider
,
new
CollectionRequest
(
properties
,
queryString
));
}
else
{
}
else
{
result
=
getResource
(
termResourceProvider
,
new
InstanceRequest
(
properties
));
result
=
getResource
(
termResourceProvider
,
new
InstanceRequest
(
properties
));
}
}
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
serializer
.
serialize
(
result
,
ui
)).
build
();
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
getSerializer
()
.
serialize
(
result
,
ui
)).
build
();
}
}
@POST
@POST
...
@@ -188,6 +186,27 @@ public class TaxonomyService extends BaseService {
...
@@ -188,6 +186,27 @@ public class TaxonomyService extends BaseService {
new
Results
(
ui
.
getRequestUri
().
toString
(),
201
)).
build
();
new
Results
(
ui
.
getRequestUri
().
toString
(),
201
)).
build
();
}
}
@POST
@Path
(
"{taxonomyName}/terms/{termName}/{remainder:.*}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
createSubTerm
(
String
body
,
@Context
HttpHeaders
headers
,
@Context
UriInfo
ui
,
@PathParam
(
"taxonomyName"
)
String
taxonomyName
,
@PathParam
(
"termName"
)
String
termName
,
@PathParam
(
"remainder"
)
String
remainder
)
throws
CatalogException
{
Map
<
String
,
Object
>
properties
=
parsePayload
(
body
);
String
[]
pathTokens
=
remainder
.
split
(
"/"
);
validateName
(
pathTokens
[
pathTokens
.
length
-
1
]);
properties
.
put
(
"termPath"
,
new
TermPath
(
taxonomyName
,
String
.
format
(
"%s%s"
,
termName
,
remainder
.
replaceAll
(
"/?terms/?([.]*)"
,
"$1."
))));
createResource
(
termResourceProvider
,
new
InstanceRequest
(
properties
));
return
Response
.
status
(
Response
.
Status
.
CREATED
).
entity
(
new
Results
(
ui
.
getRequestUri
().
toString
(),
201
)).
build
();
}
@DELETE
@DELETE
@Path
(
"{taxonomyName}/terms/{termName}"
)
@Path
(
"{taxonomyName}/terms/{termName}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
...
@@ -204,25 +223,30 @@ public class TaxonomyService extends BaseService {
...
@@ -204,25 +223,30 @@ public class TaxonomyService extends BaseService {
new
Results
(
ui
.
getRequestUri
().
toString
(),
200
)).
build
();
new
Results
(
ui
.
getRequestUri
().
toString
(),
200
)).
build
();
}
}
@
POST
@
DELETE
@Path
(
"{taxonomyName}/terms/{termName}/{remainder:.*}"
)
@Path
(
"{taxonomyName}/terms/{termName}/{remainder:.*}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Response
createSubTerms
(
String
body
,
public
Response
deleteSubTerm
(
@Context
HttpHeaders
headers
,
@Context
HttpHeaders
headers
,
@Context
UriInfo
ui
,
@Context
UriInfo
ui
,
@PathParam
(
"taxonomyName"
)
String
taxonomyName
,
@PathParam
(
"taxonomyName"
)
String
taxonomyName
,
@PathParam
(
"termName"
)
String
termName
,
@PathParam
(
"termName"
)
String
termName
,
@PathParam
(
"remainder"
)
String
remainder
)
throws
CatalogException
{
@PathParam
(
"remainder"
)
String
remainder
)
throws
CatalogException
{
Map
<
String
,
Object
>
properties
=
parsePayload
(
body
);
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
String
[]
pathTokens
=
remainder
.
split
(
"/"
);
validateName
(
pathTokens
[
pathTokens
.
length
-
1
]);
properties
.
put
(
"termPath"
,
new
TermPath
(
taxonomyName
,
String
.
format
(
"%s%s"
,
termName
,
properties
.
put
(
"termPath"
,
new
TermPath
(
taxonomyName
,
String
.
format
(
"%s%s"
,
termName
,
remainder
.
replaceAll
(
"/?terms/?([.]*)"
,
"$1."
))));
remainder
.
replaceAll
(
"/?terms/?([.]*)"
,
"$1."
))));
crea
teResource
(
termResourceProvider
,
new
InstanceRequest
(
properties
));
dele
teResource
(
termResourceProvider
,
new
InstanceRequest
(
properties
));
return
Response
.
status
(
Response
.
Status
.
CREATED
).
entity
(
return
Response
.
status
(
Response
.
Status
.
OK
).
entity
(
new
Results
(
ui
.
getRequestUri
().
toString
(),
201
)).
build
();
new
Results
(
ui
.
getRequestUri
().
toString
(),
200
)).
build
();
}
protected
ResourceProvider
createTaxonomyResourceProvider
(
AtlasTypeSystem
typeSystem
)
{
return
new
TaxonomyResourceProvider
(
typeSystem
);
}
protected
ResourceProvider
createTermResourceProvider
(
AtlasTypeSystem
typeSystem
)
{
return
new
TermResourceProvider
(
typeSystem
);
}
}
private
void
validateName
(
String
name
)
throws
InvalidPayloadException
{
private
void
validateName
(
String
name
)
throws
InvalidPayloadException
{
...
...
webapp/src/test/java/org/apache/atlas/web/resources/TaxonomyServiceTest.java
0 → 100644
View file @
d661964c
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