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
6310fed1
Commit
6310fed1
authored
Jun 05, 2015
by
Venkatesh Seetharam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG-38869 update entity for an entity that does not exist returns a 400 instead of 404
BUG-38726 add trait to an entity that does not exist returns a 400, it should return a 404
parent
3943a640
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
12 deletions
+30
-12
EntityNotFoundException.java
...e/hadoop/metadata/repository/EntityNotFoundException.java
+1
-1
GraphBackedMetadataRepository.java
...adata/repository/graph/GraphBackedMetadataRepository.java
+2
-2
EntityResource.java
.../apache/hadoop/metadata/web/resources/EntityResource.java
+24
-2
HiveLineageResource.java
...he/hadoop/metadata/web/resources/HiveLineageResource.java
+0
-1
MetadataDiscoveryResource.java
...oop/metadata/web/resources/MetadataDiscoveryResource.java
+0
-1
RexsterGraphResource.java
...e/hadoop/metadata/web/resources/RexsterGraphResource.java
+0
-1
TypesResource.java
...g/apache/hadoop/metadata/web/resources/TypesResource.java
+0
-1
EntityJerseyResourceIT.java
...hadoop/metadata/web/resources/EntityJerseyResourceIT.java
+3
-3
No files found.
repository/src/main/java/org/apache/hadoop/metadata/repository/EntityNotFoundException.java
View file @
6310fed1
...
...
@@ -23,7 +23,7 @@ import org.apache.hadoop.metadata.MetadataException;
/**
* A simple wrapper for 404.
*/
public
class
EntityNotFoundException
extends
Metadata
Exception
{
public
class
EntityNotFoundException
extends
Repository
Exception
{
public
EntityNotFoundException
()
{
}
...
...
repository/src/main/java/org/apache/hadoop/metadata/repository/graph/GraphBackedMetadataRepository.java
View file @
6310fed1
...
...
@@ -162,9 +162,9 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
public
ITypedReferenceableInstance
getEntityDefinition
(
String
guid
)
throws
RepositoryException
{
LOG
.
info
(
"Retrieving entity with guid={}"
,
guid
);
try
{
Vertex
instanceVertex
=
getVertexForGUID
(
guid
);
Vertex
instanceVertex
=
getVertexForGUID
(
guid
);
try
{
LOG
.
debug
(
"Found a vertex {} for guid {}"
,
instanceVertex
,
guid
);
return
graphToInstanceMapper
.
mapGraphToTypedInstance
(
guid
,
instanceVertex
);
...
...
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/EntityResource.java
View file @
6310fed1
...
...
@@ -21,6 +21,8 @@ package org.apache.hadoop.metadata.web.resources;
import
com.google.common.base.Preconditions
;
import
org.apache.hadoop.metadata.MetadataException
;
import
org.apache.hadoop.metadata.MetadataServiceClient
;
import
org.apache.hadoop.metadata.ParamChecker
;
import
org.apache.hadoop.metadata.repository.EntityNotFoundException
;
import
org.apache.hadoop.metadata.services.MetadataService
;
import
org.apache.hadoop.metadata.typesystem.types.ValueConversionException
;
import
org.apache.hadoop.metadata.web.util.Servlets
;
...
...
@@ -43,7 +45,6 @@ import javax.ws.rs.Produces;
import
javax.ws.rs.QueryParam
;
import
javax.ws.rs.WebApplicationException
;
import
javax.ws.rs.core.Context
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.UriBuilder
;
import
javax.ws.rs.core.UriInfo
;
...
...
@@ -131,6 +132,7 @@ public class EntityResource {
public
Response
getEntityDefinition
(
@PathParam
(
"guid"
)
String
guid
)
{
try
{
LOG
.
debug
(
"Fetching entity definition for guid={} "
,
guid
);
ParamChecker
.
notEmpty
(
guid
,
"guid cannot be null"
);
final
String
entityDefinition
=
metadataService
.
getEntityDefinition
(
guid
);
JSONObject
response
=
new
JSONObject
();
...
...
@@ -148,10 +150,14 @@ public class EntityResource {
return
Response
.
status
(
status
).
entity
(
response
).
build
();
}
catch
(
MetadataException
|
IllegalArgument
Exception
e
)
{
}
catch
(
EntityNotFound
Exception
e
)
{
LOG
.
error
(
"An entity with GUID={} does not exist"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
NOT_FOUND
));
}
catch
(
MetadataException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Bad GUID={}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get instance definition for GUID {}"
,
guid
,
e
);
throw
new
WebApplicationException
(
...
...
@@ -218,6 +224,10 @@ public class EntityResource {
JSONObject
response
=
new
JSONObject
();
response
.
put
(
MetadataServiceClient
.
REQUEST_ID
,
Thread
.
currentThread
().
getName
());
return
Response
.
ok
(
response
).
build
();
}
catch
(
EntityNotFoundException
e
)
{
LOG
.
error
(
"An entity with GUID={} does not exist"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
NOT_FOUND
));
}
catch
(
MetadataException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to add property {} to entity id {}"
,
property
,
guid
,
e
);
throw
new
WebApplicationException
(
...
...
@@ -251,6 +261,10 @@ public class EntityResource {
response
.
put
(
MetadataServiceClient
.
COUNT
,
traitNames
.
size
());
return
Response
.
ok
(
response
).
build
();
}
catch
(
EntityNotFoundException
e
)
{
LOG
.
error
(
"An entity with GUID={} does not exist"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
NOT_FOUND
));
}
catch
(
MetadataException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to get trait names for entity {}"
,
guid
,
e
);
throw
new
WebApplicationException
(
...
...
@@ -286,6 +300,10 @@ public class EntityResource {
response
.
put
(
MetadataServiceClient
.
GUID
,
guid
);
return
Response
.
created
(
locationURI
).
entity
(
response
).
build
();
}
catch
(
EntityNotFoundException
e
)
{
LOG
.
error
(
"An entity with GUID={} does not exist"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
NOT_FOUND
));
}
catch
(
MetadataException
|
IOException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to add trait for entity={}"
,
guid
,
e
);
throw
new
WebApplicationException
(
...
...
@@ -320,6 +338,10 @@ public class EntityResource {
response
.
put
(
TRAIT_NAME
,
traitName
);
return
Response
.
ok
(
response
).
build
();
}
catch
(
EntityNotFoundException
e
)
{
LOG
.
error
(
"An entity with GUID={} does not exist"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
NOT_FOUND
));
}
catch
(
MetadataException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to delete trait name={} for entity={}"
,
traitName
,
guid
,
e
);
throw
new
WebApplicationException
(
...
...
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/HiveLineageResource.java
View file @
6310fed1
...
...
@@ -33,7 +33,6 @@ import javax.inject.Singleton;
import
javax.servlet.http.HttpServletRequest
;
import
javax.ws.rs.*
;
import
javax.ws.rs.core.Context
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
/**
...
...
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/MetadataDiscoveryResource.java
View file @
6310fed1
...
...
@@ -38,7 +38,6 @@ import javax.ws.rs.Path;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.QueryParam
;
import
javax.ws.rs.WebApplicationException
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
java.util.List
;
import
java.util.Map
;
...
...
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/RexsterGraphResource.java
View file @
6310fed1
...
...
@@ -46,7 +46,6 @@ import javax.ws.rs.PathParam;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.QueryParam
;
import
javax.ws.rs.WebApplicationException
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/TypesResource.java
View file @
6310fed1
...
...
@@ -43,7 +43,6 @@ import javax.ws.rs.Produces;
import
javax.ws.rs.QueryParam
;
import
javax.ws.rs.WebApplicationException
;
import
javax.ws.rs.core.Context
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
...
...
webapp/src/test/java/org/apache/hadoop/metadata/web/resources/EntityJerseyResourceIT.java
View file @
6310fed1
...
...
@@ -389,7 +389,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
@Test
(
dependsOnMethods
=
"testAddTrait"
)
public
void
testAddExistingTrait
()
throws
Exception
{
final
String
traitName
=
"PII_Trait"
;
final
String
traitName
=
"PII_Trait"
+
randomString
()
;
Struct
traitInstance
=
new
Struct
(
traitName
);
String
traitInstanceAsJSON
=
InstanceSerialization
.
toJson
(
traitInstance
,
true
);
...
...
@@ -408,7 +408,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
@Test
(
dependsOnMethods
=
"testGetTraitNames"
)
public
void
testAddTraitWithAttribute
()
throws
Exception
{
final
String
traitName
=
"P_I_I"
;
final
String
traitName
=
"PII_Trait"
+
randomString
()
;
HierarchicalTypeDefinition
<
TraitType
>
piiTrait
=
TypesUtil
.
createTraitTypeDef
(
traitName
,
ImmutableList
.<
String
>
of
(),
TypesUtil
.
createRequiredAttrDef
(
"type"
,
DataTypes
.
STRING_TYPE
));
...
...
@@ -456,7 +456,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
@Test
public
void
testAddTraitWithNoRegistration
()
throws
Exception
{
final
String
traitName
=
"PII_Trait
_Blah"
;
final
String
traitName
=
"PII_Trait
"
+
randomString
()
;
HierarchicalTypeDefinition
<
TraitType
>
piiTrait
=
TypesUtil
.
createTraitTypeDef
(
traitName
,
ImmutableList
.<
String
>
of
());
String
traitDefinitionAsJSON
=
TypesSerialization
$
.
MODULE
$
.
toJson
(
piiTrait
,
true
);
...
...
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