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
b1717f2e
Commit
b1717f2e
authored
Feb 27, 2017
by
Sarath Subramanian
Committed by
Madhan Neethiraj
Feb 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1602: fixed IT failures in QuickStart and issues identified in coverity scan
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
8bb31fdf
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
199 additions
and
84 deletions
+199
-84
AtlasBaseClient.java
client/src/main/java/org/apache/atlas/AtlasBaseClient.java
+0
-2
AtlasClient.java
client/src/main/java/org/apache/atlas/AtlasClient.java
+6
-5
AtlasInstanceConverter.java
...e/atlas/repository/converters/AtlasInstanceConverter.java
+5
-0
QuickStart.java
...p/src/main/java/org/apache/atlas/examples/QuickStart.java
+54
-51
QuickStartV2.java
...src/main/java/org/apache/atlas/examples/QuickStartV2.java
+0
-4
DataSetLineageResource.java
...rg/apache/atlas/web/resources/DataSetLineageResource.java
+9
-0
EntityResource.java
...n/java/org/apache/atlas/web/resources/EntityResource.java
+71
-7
LineageResource.java
.../java/org/apache/atlas/web/resources/LineageResource.java
+11
-2
MetadataDiscoveryResource.java
...apache/atlas/web/resources/MetadataDiscoveryResource.java
+9
-0
TypesResource.java
...in/java/org/apache/atlas/web/resources/TypesResource.java
+15
-6
Servlets.java
webapp/src/main/java/org/apache/atlas/web/util/Servlets.java
+8
-0
QuickStartV2IT.java
...c/test/java/org/apache/atlas/examples/QuickStartV2IT.java
+7
-5
EntityResourceTest.java
...va/org/apache/atlas/web/resources/EntityResourceTest.java
+4
-2
No files found.
client/src/main/java/org/apache/atlas/AtlasBaseClient.java
View file @
b1717f2e
...
...
@@ -32,7 +32,6 @@ import javax.ws.rs.core.UriBuilder;
import
org.apache.atlas.model.metrics.AtlasMetrics
;
import
org.apache.atlas.security.SecureClientUtils
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.utils.AuthenticationUtil
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -319,7 +318,6 @@ public abstract class AtlasBaseClient {
}
}
else
{
T
entity
=
clientResponse
.
getEntity
(
responseType
);
LOG
.
info
(
"Response = {}"
,
AtlasType
.
toJson
(
entity
));
return
entity
;
}
}
catch
(
ClientHandlerException
e
)
{
...
...
client/src/main/java/org/apache/atlas/AtlasClient.java
View file @
b1717f2e
...
...
@@ -20,8 +20,9 @@ package org.apache.atlas;
import
com.google.common.annotations.VisibleForTesting
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.gson.Gson
;
import
com.google.gson.GsonBuilder
;
import
com.sun.jersey.api.client.WebResource
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.typesystem.Referenceable
;
import
org.apache.atlas.typesystem.Struct
;
import
org.apache.atlas.typesystem.TypesDef
;
...
...
@@ -259,6 +260,8 @@ public class AtlasClient extends AtlasBaseClient {
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
PROPERTY
)
public
static
class
EntityResult
{
private
static
final
Gson
gson
=
new
GsonBuilder
().
setPrettyPrinting
().
create
();
public
static
final
String
OP_CREATED
=
"created"
;
public
static
final
String
OP_UPDATED
=
"updated"
;
public
static
final
String
OP_DELETED
=
"deleted"
;
...
...
@@ -314,12 +317,10 @@ public class AtlasClient extends AtlasBaseClient {
}
@Override
public
String
toString
()
{
return
AtlasType
.
toJson
(
this
);
}
public
String
toString
()
{
return
gson
.
toJson
(
this
);
}
public
static
EntityResult
fromString
(
String
json
)
throws
AtlasServiceException
{
return
AtlasType
.
fromJson
(
json
,
EntityResult
.
class
);
return
gson
.
fromJson
(
json
,
EntityResult
.
class
);
}
}
...
...
repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
View file @
b1717f2e
...
...
@@ -56,6 +56,7 @@ import org.slf4j.LoggerFactory;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -281,24 +282,28 @@ public class AtlasInstanceConverter {
case
CREATE:
List
<
AtlasEntityHeader
>
createdEntities
=
mutatedEntities
.
get
(
EntityOperation
.
CREATE
);
if
(
CollectionUtils
.
isNotEmpty
(
createdEntities
))
{
Collections
.
reverse
(
createdEntities
);
entityResult
.
set
(
EntityResult
.
OP_CREATED
,
getGuids
(
createdEntities
));
}
break
;
case
UPDATE:
List
<
AtlasEntityHeader
>
updatedEntities
=
mutatedEntities
.
get
(
EntityOperation
.
UPDATE
);
if
(
CollectionUtils
.
isNotEmpty
(
updatedEntities
))
{
Collections
.
reverse
(
updatedEntities
);
entityResult
.
set
(
EntityResult
.
OP_UPDATED
,
getGuids
(
updatedEntities
));
}
break
;
case
PARTIAL_UPDATE:
List
<
AtlasEntityHeader
>
partialUpdatedEntities
=
mutatedEntities
.
get
(
EntityOperation
.
PARTIAL_UPDATE
);
if
(
CollectionUtils
.
isNotEmpty
(
partialUpdatedEntities
))
{
Collections
.
reverse
(
partialUpdatedEntities
);
entityResult
.
set
(
EntityResult
.
OP_UPDATED
,
getGuids
(
partialUpdatedEntities
));
}
break
;
case
DELETE:
List
<
AtlasEntityHeader
>
deletedEntities
=
mutatedEntities
.
get
(
EntityOperation
.
DELETE
);
if
(
CollectionUtils
.
isNotEmpty
(
deletedEntities
))
{
Collections
.
reverse
(
deletedEntities
);
entityResult
.
set
(
EntityResult
.
OP_DELETED
,
getGuids
(
deletedEntities
));
}
break
;
...
...
webapp/src/main/java/org/apache/atlas/examples/QuickStart.java
View file @
b1717f2e
...
...
@@ -55,7 +55,7 @@ public class QuickStart {
public
static
final
String
SALES_DB
=
"Sales"
;
public
static
final
String
SALES_DB_DESCRIPTION
=
"Sales Database"
;
public
static
final
String
SALES_FACT_TABLE
=
"sales_fact"
;
public
static
final
String
FACT_TRAIT
=
"Fact"
;
public
static
final
String
FACT_TRAIT
=
"Fact
_v1
"
;
public
static
final
String
COLUMNS_ATTRIBUTE
=
"columns"
;
public
static
final
String
TIME_ID_COLUMN
=
"time_id"
;
public
static
final
String
DB_ATTRIBUTE
=
"db"
;
...
...
@@ -115,16 +115,16 @@ public class QuickStart {
return
urls
;
}
static
final
String
DATABASE_TYPE
=
"DB"
;
static
final
String
COLUMN_TYPE
=
"Column"
;
static
final
String
TABLE_TYPE
=
"Table"
;
static
final
String
VIEW_TYPE
=
"View"
;
static
final
String
LOAD_PROCESS_TYPE
=
"LoadProcess"
;
static
final
String
STORAGE_DESC_TYPE
=
"StorageDesc"
;
static
final
String
DATABASE_TYPE
=
"DB
_v1
"
;
static
final
String
COLUMN_TYPE
=
"Column
_v1
"
;
static
final
String
TABLE_TYPE
=
"Table
_v1
"
;
static
final
String
VIEW_TYPE
=
"View
_v1
"
;
static
final
String
LOAD_PROCESS_TYPE
=
"LoadProcess
_v1
"
;
static
final
String
STORAGE_DESC_TYPE
=
"StorageDesc
_v1
"
;
private
static
final
String
[]
TYPES
=
{
DATABASE_TYPE
,
TABLE_TYPE
,
STORAGE_DESC_TYPE
,
COLUMN_TYPE
,
LOAD_PROCESS_TYPE
,
VIEW_TYPE
,
"JdbcAccess"
,
"ETL
"
,
"Metric"
,
"PII"
,
"Fact"
,
"Dimension"
,
"Log Data
"
};
{
DATABASE_TYPE
,
TABLE_TYPE
,
STORAGE_DESC_TYPE
,
COLUMN_TYPE
,
LOAD_PROCESS_TYPE
,
VIEW_TYPE
,
"JdbcAccess
_v1
"
,
"ETL
_v1"
,
"Metric_v1"
,
"PII_v1"
,
"Fact_v1"
,
"Dimension_v1"
,
"Log Data_v1
"
};
private
final
AtlasClient
metadataServiceClient
;
...
...
@@ -191,19 +191,19 @@ public class QuickStart {
new
AttributeDefinition
(
"inputTables"
,
DataTypes
.
arrayTypeName
(
TABLE_TYPE
),
Multiplicity
.
COLLECTION
,
false
,
null
));
HierarchicalTypeDefinition
<
TraitType
>
dimTraitDef
=
TypesUtil
.
createTraitTypeDef
(
"Dimension"
,
"Dimension Trait"
,
null
);
HierarchicalTypeDefinition
<
TraitType
>
dimTraitDef
=
TypesUtil
.
createTraitTypeDef
(
"Dimension
_v1
"
,
"Dimension Trait"
,
null
);
HierarchicalTypeDefinition
<
TraitType
>
factTraitDef
=
TypesUtil
.
createTraitTypeDef
(
"Fact"
,
"Fact Trait"
,
null
);
HierarchicalTypeDefinition
<
TraitType
>
factTraitDef
=
TypesUtil
.
createTraitTypeDef
(
"Fact
_v1
"
,
"Fact Trait"
,
null
);
HierarchicalTypeDefinition
<
TraitType
>
piiTraitDef
=
TypesUtil
.
createTraitTypeDef
(
"PII"
,
"PII Trait"
,
null
);
HierarchicalTypeDefinition
<
TraitType
>
piiTraitDef
=
TypesUtil
.
createTraitTypeDef
(
"PII
_v1
"
,
"PII Trait"
,
null
);
HierarchicalTypeDefinition
<
TraitType
>
metricTraitDef
=
TypesUtil
.
createTraitTypeDef
(
"Metric"
,
"Metric Trait"
,
null
);
HierarchicalTypeDefinition
<
TraitType
>
metricTraitDef
=
TypesUtil
.
createTraitTypeDef
(
"Metric
_v1
"
,
"Metric Trait"
,
null
);
HierarchicalTypeDefinition
<
TraitType
>
etlTraitDef
=
TypesUtil
.
createTraitTypeDef
(
"ETL"
,
"ETL Trait"
,
null
);
HierarchicalTypeDefinition
<
TraitType
>
etlTraitDef
=
TypesUtil
.
createTraitTypeDef
(
"ETL
_v1
"
,
"ETL Trait"
,
null
);
HierarchicalTypeDefinition
<
TraitType
>
jdbcTraitDef
=
TypesUtil
.
createTraitTypeDef
(
"JdbcAccess"
,
"JdbcAccess Trait"
,
null
);
HierarchicalTypeDefinition
<
TraitType
>
jdbcTraitDef
=
TypesUtil
.
createTraitTypeDef
(
"JdbcAccess
_v1
"
,
"JdbcAccess Trait"
,
null
);
HierarchicalTypeDefinition
<
TraitType
>
logTraitDef
=
TypesUtil
.
createTraitTypeDef
(
"Log Data"
,
"LogData Trait"
,
null
);
HierarchicalTypeDefinition
<
TraitType
>
logTraitDef
=
TypesUtil
.
createTraitTypeDef
(
"Log Data
_v1
"
,
"LogData Trait"
,
null
);
return
TypesUtil
.
getTypesDef
(
ImmutableList
.<
EnumTypeDefinition
>
of
(),
ImmutableList
.<
StructTypeDefinition
>
of
(),
ImmutableList
.
of
(
dimTraitDef
,
factTraitDef
,
piiTraitDef
,
metricTraitDef
,
etlTraitDef
,
jdbcTraitDef
,
logTraitDef
),
...
...
@@ -235,12 +235,12 @@ public class QuickStart {
List
<
Referenceable
>
salesFactColumns
=
ImmutableList
.
of
(
rawColumn
(
TIME_ID_COLUMN
,
"int"
,
"time id"
),
rawColumn
(
"product_id"
,
"int"
,
"product id"
),
rawColumn
(
"customer_id"
,
"int"
,
"customer id"
,
"PII"
),
rawColumn
(
"sales"
,
"double"
,
"product id"
,
"Metric"
));
rawColumn
(
"customer_id"
,
"int"
,
"customer id"
,
"PII
_v1
"
),
rawColumn
(
"sales"
,
"double"
,
"product id"
,
"Metric
_v1
"
));
List
<
Referenceable
>
logFactColumns
=
ImmutableList
.
of
(
rawColumn
(
"time_id"
,
"int"
,
"time id"
),
rawColumn
(
"app_id"
,
"int"
,
"app id"
),
rawColumn
(
"machine_id"
,
"int"
,
"machine id"
),
rawColumn
(
"log"
,
"string"
,
"log data"
,
"Log Data"
));
rawColumn
(
"machine_id"
,
"int"
,
"machine id"
),
rawColumn
(
"log"
,
"string"
,
"log data"
,
"Log Data
_v1
"
));
Id
salesFact
=
table
(
SALES_FACT_TABLE
,
SALES_FACT_TABLE_DESCRIPTION
,
salesDB
,
sd
,
"Joe"
,
"Managed"
,
salesFactColumns
,
FACT_TRAIT
);
...
...
@@ -251,23 +251,23 @@ public class QuickStart {
Id
productDim
=
table
(
PRODUCT_DIM_TABLE
,
"product dimension table"
,
salesDB
,
sd
,
"John Doe"
,
"Managed"
,
productDimColumns
,
"Dimension"
);
productDimColumns
,
"Dimension
_v1
"
);
List
<
Referenceable
>
timeDimColumns
=
ImmutableList
.
of
(
rawColumn
(
"time_id"
,
"int"
,
"time id"
),
rawColumn
(
"dayOfYear"
,
"int"
,
"day Of Year"
),
rawColumn
(
"weekDay"
,
"int"
,
"week Day"
));
Id
timeDim
=
table
(
TIME_DIM_TABLE
,
"time dimension table"
,
salesDB
,
sd
,
"John Doe"
,
"External"
,
timeDimColumns
,
"Dimension"
);
"Dimension
_v1
"
);
List
<
Referenceable
>
customerDimColumns
=
ImmutableList
.
of
(
rawColumn
(
"customer_id"
,
"int"
,
"customer id"
,
"PII"
),
rawColumn
(
"name"
,
"string"
,
"customer name"
,
"PII"
),
rawColumn
(
"address"
,
"string"
,
"customer address"
,
"PII"
));
List
<
Referenceable
>
customerDimColumns
=
ImmutableList
.
of
(
rawColumn
(
"customer_id"
,
"int"
,
"customer id"
,
"PII
_v1
"
),
rawColumn
(
"name"
,
"string"
,
"customer name"
,
"PII
_v1
"
),
rawColumn
(
"address"
,
"string"
,
"customer address"
,
"PII
_v1
"
));
Id
customerDim
=
table
(
"customer_dim"
,
"customer dimension table"
,
salesDB
,
sd
,
"fetl"
,
"External"
,
customerDimColumns
,
"Dimension"
);
"Dimension
_v1
"
);
Id
reportingDB
=
...
...
@@ -277,33 +277,33 @@ public class QuickStart {
Id
salesFactDaily
=
table
(
SALES_FACT_DAILY_MV_TABLE
,
"sales fact daily materialized view"
,
reportingDB
,
sd
,
"Joe BI"
,
"Managed"
,
salesFactColumns
,
"Metric"
);
"Managed"
,
salesFactColumns
,
"Metric
_v1
"
);
Id
loggingFactDaily
=
table
(
"log_fact_daily_mv"
,
"log fact daily materialized view"
,
logDB
,
sd
,
"Tim ETL"
,
"Managed"
,
logFactColumns
,
"Log Data"
);
logFactColumns
,
"Log Data
_v1
"
);
loadProcess
(
LOAD_SALES_DAILY_PROCESS
,
LOAD_SALES_DAILY_PROCESS_DESCRIPTION
,
"John ETL"
,
ImmutableList
.
of
(
salesFact
,
timeDim
),
ImmutableList
.
of
(
salesFactDaily
),
"create table as select "
,
"plan"
,
"id"
,
"graph"
,
"ETL"
);
ImmutableList
.
of
(
salesFactDaily
),
"create table as select "
,
"plan"
,
"id"
,
"graph"
,
"ETL
_v1
"
);
view
(
PRODUCT_DIM_VIEW
,
reportingDB
,
ImmutableList
.
of
(
productDim
),
"Dimension
"
,
"JdbcAccess
"
);
view
(
PRODUCT_DIM_VIEW
,
reportingDB
,
ImmutableList
.
of
(
productDim
),
"Dimension
_v1"
,
"JdbcAccess_v1
"
);
view
(
"customer_dim_view"
,
reportingDB
,
ImmutableList
.
of
(
customerDim
),
"Dimension
"
,
"JdbcAccess
"
);
view
(
"customer_dim_view"
,
reportingDB
,
ImmutableList
.
of
(
customerDim
),
"Dimension
_v1"
,
"JdbcAccess_v1
"
);
Id
salesFactMonthly
=
table
(
"sales_fact_monthly_mv"
,
"sales fact monthly materialized view"
,
reportingDB
,
sd
,
"Jane BI"
,
"Managed"
,
salesFactColumns
,
"Metric"
);
"Managed"
,
salesFactColumns
,
"Metric
_v1
"
);
loadProcess
(
"loadSalesMonthly"
,
"hive query for monthly summary"
,
"John ETL"
,
ImmutableList
.
of
(
salesFactDaily
),
ImmutableList
.
of
(
salesFactMonthly
),
"create table as select "
,
"plan"
,
"id"
,
"graph"
,
"ETL"
);
ImmutableList
.
of
(
salesFactMonthly
),
"create table as select "
,
"plan"
,
"id"
,
"graph"
,
"ETL
_v1
"
);
Id
loggingFactMonthly
=
table
(
"logging_fact_monthly_mv"
,
"logging fact monthly materialized view"
,
logDB
,
sd
,
"Tim ETL"
,
"Managed"
,
logFactColumns
,
"Log Data"
);
"Managed"
,
logFactColumns
,
"Log Data
_v1
"
);
loadProcess
(
"loadLogsMonthly"
,
"hive query for monthly summary"
,
"Tim ETL"
,
ImmutableList
.
of
(
loggingFactDaily
),
ImmutableList
.
of
(
loggingFactMonthly
),
"create table as select "
,
"plan"
,
"id"
,
"graph"
,
"ETL"
);
ImmutableList
.
of
(
loggingFactMonthly
),
"create table as select "
,
"plan"
,
"id"
,
"graph"
,
"ETL
_v1
"
);
}
private
Id
createInstance
(
Referenceable
referenceable
)
throws
Exception
{
...
...
@@ -315,8 +315,11 @@ public class QuickStart {
System
.
out
.
println
(
"created instance for type "
+
typeName
+
", guid: "
+
guids
);
// return the Id for created instance with guid
return
new
Id
(
guids
.
get
(
guids
.
size
()
-
1
),
referenceable
.
getId
().
getVersion
(),
referenceable
.
getTypeName
());
if
(
guids
.
size
()
>
0
)
{
return
new
Id
(
guids
.
get
(
guids
.
size
()
-
1
),
referenceable
.
getId
().
getVersion
(),
referenceable
.
getTypeName
());
}
return
null
;
}
Id
database
(
String
name
,
String
description
,
String
owner
,
String
locationUri
,
String
...
traitNames
)
...
...
@@ -411,23 +414,23 @@ public class QuickStart {
}
private
String
[]
getDSLQueries
()
{
return
new
String
[]{
"from DB
"
,
"DB"
,
"DB where name=\"Reporting\""
,
"DB where DB
.name=\"Reporting\""
,
"DB
name = \"Reporting\""
,
"DB DB
.name = \"Reporting\""
,
"DB
where name=\"Reporting\" select name, owner"
,
"DB where DB
.name=\"Reporting\" select name, owner"
,
"DB
has name"
,
"DB where DB has name"
,
"DB, Table"
,
"DB
is JdbcAccess"
,
return
new
String
[]{
"from DB
_v1"
,
"DB_v1"
,
"DB_v1 where name=\"Reporting\""
,
"DB_v1 where DB_v1
.name=\"Reporting\""
,
"DB
_v1 name = \"Reporting\""
,
"DB_v1 DB_v1
.name = \"Reporting\""
,
"DB
_v1 where name=\"Reporting\" select name, owner"
,
"DB_v1 where DB_v1
.name=\"Reporting\" select name, owner"
,
"DB
_v1 has name"
,
"DB_v1 where DB_v1 has name"
,
"DB_v1, Table_v1"
,
"DB_v1
is JdbcAccess"
,
/*
"DB, hive_process has name",
"DB as db1, Table where db1.name = \"Reporting\"",
"DB where DB.name=\"Reporting\" and DB.createTime < " + System.currentTimeMillis()},
*/
"from Table
"
,
"Table"
,
"Table is Dimension"
,
"Column where Column isa PII"
,
"View is Dimension
"
,
"from Table
_v1"
,
"Table_v1"
,
"Table_v1 is Dimension_v1"
,
"Column_v1 where Column_v1 isa PII_v1"
,
"View_v1 is Dimension_v1
"
,
/*"Column where Column isa PII select Column.name",*/
"Column
select Column.name"
,
"Column select name"
,
"Column where Column
.name=\"customer_id\""
,
"from Table
select Table.name"
,
"DB
where (name = \"Reporting\")"
,
"DB
where (name = \"Reporting\") select name as _col_0, owner as _col_1"
,
"DB where DB is JdbcAccess
"
,
"DB
where DB has name"
,
"DB Table"
,
"DB where DB
has name"
,
"DB as db1 Table where (db1.name = \"Reporting\")"
,
"DB where (name = \"Reporting\") select name as _col_0, (createTime + 1) as _col_1 "
,
"Column
_v1 select Column_v1.name"
,
"Column_v1 select name"
,
"Column_v1 where Column_v1
.name=\"customer_id\""
,
"from Table
_v1 select Table_v1.name"
,
"DB_v1
where (name = \"Reporting\")"
,
"DB
_v1 where (name = \"Reporting\") select name as _col_0, owner as _col_1"
,
"DB_v1 where DB_v1 is JdbcAccess_v1
"
,
"DB
_v1 where DB_v1 has name"
,
"DB_v1 Table_v1"
,
"DB_v1 where DB_v1
has name"
,
"DB
_v1
as db1 Table where (db1.name = \"Reporting\")"
,
"DB
_v1
where (name = \"Reporting\") select name as _col_0, (createTime + 1) as _col_1 "
,
/*
todo: does not work
"DB where (name = \"Reporting\") and ((createTime + 1) > 0)",
...
...
@@ -441,9 +444,9 @@ public class QuickStart {
select db1.name as dbName, tab.name as tabName",
*/
// trait searches
"Dimension"
,
"Dimension
_v1
"
,
/*"Fact", - todo: does not work*/
"JdbcAccess
"
,
"ETL"
,
"Metric"
,
"PII"
,
"`Log Data
`"
,
"JdbcAccess
_v1"
,
"ETL_v1"
,
"Metric_v1"
,
"PII_v1"
,
"`Log Data_v1
`"
,
/*
// Lineage - todo - fix this, its not working
"Table hive_process outputTables",
...
...
@@ -452,8 +455,8 @@ public class QuickStart {
"Table as src loop (hive_process outputTables) as dest select src.name as srcTable, dest.name as
destTable withPath",
*/
"Table where name=\"sales_fact\", columns"
,
"Table where name=\"sales_fact\", columns as column select column.name, column.dataType, column"
"Table
_v1
where name=\"sales_fact\", columns"
,
"Table
_v1
where name=\"sales_fact\", columns as column select column.name, column.dataType, column"
+
".comment"
,
"from DataSet"
,
"from Process"
,};
}
...
...
webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java
View file @
b1717f2e
...
...
@@ -350,10 +350,6 @@ public class QuickStartV2 {
System
.
out
.
println
(
"Created entity of type ["
+
ret
.
getTypeName
()
+
"], guid: "
+
ret
.
getGuid
());
}
if
(
ArrayUtils
.
isNotEmpty
(
traitNames
))
{
entitiesClient
.
addClassifications
(
ret
.
getGuid
(),
toAtlasClassifications
(
traitNames
));
}
return
ret
;
}
...
...
webapp/src/main/java/org/apache/atlas/web/resources/DataSetLineageResource.java
View file @
b1717f2e
...
...
@@ -98,6 +98,9 @@ public class DataSetLineageResource {
}
catch
(
DiscoveryException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to get lineage inputs graph for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get lineage inputs graph for table {}"
,
tableName
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get lineage inputs graph for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -141,6 +144,9 @@ public class DataSetLineageResource {
}
catch
(
DiscoveryException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to get lineage outputs graph for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get lineage outputs graph for table {}"
,
tableName
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get lineage outputs graph for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -184,6 +190,9 @@ public class DataSetLineageResource {
}
catch
(
DiscoveryException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to get schema for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get schema for table {}"
,
tableName
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get schema for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java
View file @
b1717f2e
...
...
@@ -35,7 +35,6 @@ import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
import
org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo
;
import
org.apache.atlas.model.instance.EntityMutationResponse
;
import
org.apache.atlas.model.instance.GuidMapping
;
import
org.apache.atlas.repository.converters.AtlasFormatConverter.ConverterContext
;
import
org.apache.atlas.repository.converters.AtlasInstanceConverter
;
import
org.apache.atlas.repository.store.graph.AtlasEntityStore
;
import
org.apache.atlas.services.MetadataService
;
...
...
@@ -47,8 +46,6 @@ import org.apache.atlas.typesystem.ITypedReferenceableInstance;
import
org.apache.atlas.typesystem.Referenceable
;
import
org.apache.atlas.typesystem.exception.EntityExistsException
;
import
org.apache.atlas.typesystem.exception.EntityNotFoundException
;
import
org.apache.atlas.typesystem.exception.TraitNotFoundException
;
import
org.apache.atlas.typesystem.exception.TypeNotFoundException
;
import
org.apache.atlas.typesystem.json.InstanceSerialization
;
import
org.apache.atlas.typesystem.types.ValueConversionException
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
...
...
@@ -174,6 +171,9 @@ public class EntityResource {
return
Response
.
created
(
locationURI
).
entity
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to persist entity instance entityDef={}"
,
entityJson
,
e
);
throw
toWebApplicationException
(
e
);
}
catch
(
EntityExistsException
e
)
{
LOG
.
error
(
"Unique constraint violation for entity entityDef={}"
,
entityJson
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
CONFLICT
));
...
...
@@ -183,6 +183,9 @@ public class EntityResource {
}
catch
(
AtlasException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to persist entity instance entityDef={}"
,
entityJson
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to persist entity instance entityDef={}"
,
entityJson
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to persist entity instance entityDef={}"
,
entityJson
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -276,6 +279,9 @@ public class EntityResource {
JSONObject
response
=
getResponse
(
result
);
return
Response
.
ok
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to persist entity instance entityDef={}"
,
entityJson
,
e
);
throw
toWebApplicationException
(
e
);
}
catch
(
EntityExistsException
e
)
{
LOG
.
error
(
"Unique constraint violation for entityDef={}"
,
entityJson
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
CONFLICT
));
...
...
@@ -285,6 +291,9 @@ public class EntityResource {
}
catch
(
AtlasException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to persist entity instance entityDef={}"
,
entityJson
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to persist entity instance entityDef={}"
,
entityJson
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to persist entity instance entityDef={}"
,
entityJson
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -370,6 +379,9 @@ public class EntityResource {
JSONObject
response
=
getResponse
(
result
);
return
Response
.
ok
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to partially update entity {} {}:{}.{}"
,
entityJson
,
entityType
,
attribute
,
value
,
e
);
throw
toWebApplicationException
(
e
);
}
catch
(
ValueConversionException
ve
)
{
LOG
.
error
(
"Unable to persist entity instance due to a deserialization error {} "
,
entityJson
,
ve
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
ve
.
getCause
(),
Response
.
Status
.
BAD_REQUEST
));
...
...
@@ -382,6 +394,9 @@ public class EntityResource {
}
catch
(
AtlasException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to partially update entity {} {}:{}.{}"
,
entityJson
,
entityType
,
attribute
,
value
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to partially update entity {} {}:{}.{}"
,
entityJson
,
entityType
,
attribute
,
value
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to partially update entity {} {}:{}.{}"
,
entityJson
,
entityType
,
attribute
,
value
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -455,12 +470,18 @@ public class EntityResource {
JSONObject
response
=
getResponse
(
result
);
return
Response
.
ok
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to update entity by GUID {} {} "
,
guid
,
entityJson
,
e
);
throw
toWebApplicationException
(
e
);
}
catch
(
EntityNotFoundException
e
)
{
LOG
.
error
(
"An entity with GUID={} does not exist {} "
,
guid
,
entityJson
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
NOT_FOUND
));
}
catch
(
AtlasException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to update entity by GUID {} {}"
,
guid
,
entityJson
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to update entity by GUID {} {} "
,
guid
,
entityJson
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to update entity by GUID {} {} "
,
guid
,
entityJson
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -497,12 +518,18 @@ public class EntityResource {
JSONObject
response
=
getResponse
(
result
);
return
Response
.
ok
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to add property {} to entity id {} {} "
,
property
,
guid
,
value
,
e
);
throw
toWebApplicationException
(
e
);
}
catch
(
EntityNotFoundException
e
)
{
LOG
.
error
(
"An entity with GUID={} does not exist {} "
,
guid
,
value
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
NOT_FOUND
));
}
catch
(
AtlasException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to add property {} to entity id {} {} "
,
property
,
guid
,
value
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to add property {} to entity id {} {} "
,
property
,
guid
,
value
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to add property {} to entity id {} {} "
,
property
,
guid
,
value
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -565,6 +592,9 @@ public class EntityResource {
JSONObject
response
=
getResponse
(
entityResult
);
return
Response
.
ok
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to delete entities {} {} {} {} "
,
guids
,
entityType
,
attribute
,
value
,
e
);
throw
toWebApplicationException
(
e
);
}
catch
(
EntityNotFoundException
e
)
{
if
(
guids
!=
null
&&
!
guids
.
isEmpty
())
{
LOG
.
error
(
"An entity with GUID={} does not exist "
,
guids
,
e
);
...
...
@@ -575,6 +605,9 @@ public class EntityResource {
}
catch
(
AtlasException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to delete entities {} {} {} {} "
,
guids
,
entityType
,
attribute
,
value
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to delete entities {} {} {} {} "
,
guids
,
entityType
,
attribute
,
value
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to delete entities {} {} {} {} "
,
guids
,
entityType
,
attribute
,
value
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -633,6 +666,9 @@ public class EntityResource {
}
catch
(
AtlasException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Bad GUID={} "
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get instance definition for GUID {}"
,
guid
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get instance definition for GUID {}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -673,6 +709,9 @@ public class EntityResource {
}
catch
(
AtlasException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to get entity list for type {}"
,
entityType
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get entity list for type {}"
,
entityType
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get entity list for type {}"
,
entityType
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -736,8 +775,8 @@ public class EntityResource {
try
{
entityInfo
=
entitiesStore
.
getByUniqueAttributes
(
getEntityType
(
entityType
),
attributes
);
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Cannot find entity with type: {
0}, attribute: {1} and value: {2
}"
,
entityType
,
attribute
,
value
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
)
);
LOG
.
error
(
"Cannot find entity with type: {
}, attribute: {} and value: {
}"
,
entityType
,
attribute
,
value
);
throw
toWebApplicationException
(
e
);
}
String
entityDefinition
=
null
;
...
...
@@ -763,9 +802,15 @@ public class EntityResource {
return
Response
.
status
(
status
).
entity
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to get instance definition for type={}, qualifiedName={}"
,
entityType
,
value
,
e
);
throw
toWebApplicationException
(
e
);
}
catch
(
IllegalArgumentException
e
)
{
LOG
.
error
(
"Bad type={}, qualifiedName={}"
,
entityType
,
value
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get instance definition for type={}, qualifiedName={}"
,
entityType
,
value
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get instance definition for type={}, qualifiedName={}"
,
entityType
,
value
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -818,6 +863,9 @@ public class EntityResource {
}
catch
(
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to get trait definition for entity {}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get trait names for entity {}"
,
guid
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get trait names for entity {}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -872,6 +920,9 @@ public class EntityResource {
}
catch
(
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to get trait definition for entity {}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get trait definitions for entity {}"
,
guid
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get trait definitions for entity {}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -925,6 +976,9 @@ public class EntityResource {
}
catch
(
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to get trait definition for entity {} and trait {}"
,
guid
,
traitName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get trait definition for entity {} and trait {}"
,
guid
,
traitName
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get trait definition for entity {} and trait {}"
,
guid
,
traitName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -984,6 +1038,9 @@ public class EntityResource {
}
catch
(
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to add trait for entity={} traitDef={}"
,
guid
,
traitDefinition
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to add trait for entity={} traitDef={}"
,
guid
,
traitDefinition
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to add trait for entity={} traitDef={}"
,
guid
,
traitDefinition
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -1036,6 +1093,9 @@ public class EntityResource {
}
catch
(
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to delete trait name={} for entity={}"
,
traitName
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to delete trait name={} for entity={}"
,
traitName
,
guid
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to delete trait name={} for entity={}"
,
traitName
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -1087,6 +1147,9 @@ public class EntityResource {
}
catch
(
AtlasException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to get audit events for entity guid={} startKey={}"
,
guid
,
startKey
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get audit events for entity guid={} startKey={}"
,
guid
,
startKey
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get audit events for entity guid={} startKey={}"
,
guid
,
startKey
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -1113,7 +1176,8 @@ public class EntityResource {
public
static
WebApplicationException
toWebApplicationException
(
AtlasBaseException
e
)
{
if
(
e
.
getAtlasErrorCode
()
==
AtlasErrorCode
.
CLASSIFICATION_NOT_FOUND
||
e
.
getAtlasErrorCode
()
==
AtlasErrorCode
.
INSTANCE_GUID_NOT_FOUND
)
{
||
e
.
getAtlasErrorCode
()
==
AtlasErrorCode
.
INSTANCE_GUID_NOT_FOUND
||
e
.
getAtlasErrorCode
()
==
AtlasErrorCode
.
INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND
)
{
return
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
NOT_FOUND
));
}
...
...
@@ -1122,6 +1186,6 @@ public class EntityResource {
return
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
return
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
return
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
e
.
getAtlasErrorCode
().
getHttpCode
()
));
}
}
webapp/src/main/java/org/apache/atlas/web/resources/LineageResource.java
View file @
b1717f2e
...
...
@@ -99,7 +99,10 @@ public class LineageResource {
return
Response
.
ok
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to get lineage inputs graph for entity guid={}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
e
.
getAtlasErrorCode
().
getHttpCode
()));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get lineage inputs graph for entity guid={}"
,
guid
,
e
);
throw
e
;
}
catch
(
JSONException
e
)
{
LOG
.
error
(
"Unable to get lineage inputs graph for entity guid={}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -143,7 +146,10 @@ public class LineageResource {
return
Response
.
ok
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to get lineage outputs graph for entity guid={}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
e
.
getAtlasErrorCode
().
getHttpCode
()));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get lineage outputs graph for entity guid={}"
,
guid
,
e
);
throw
e
;
}
catch
(
JSONException
e
)
{
LOG
.
error
(
"Unable to get lineage outputs graph for entity guid={}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -192,6 +198,9 @@ public class LineageResource {
}
catch
(
DiscoveryException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to get schema for entity guid={}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get schema for entity guid={}"
,
guid
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get schema for entity={}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
View file @
b1717f2e
...
...
@@ -150,6 +150,9 @@ public class MetadataDiscoveryResource {
}
catch
(
DiscoveryException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to get entity list for dslQuery {}"
,
dslQuery
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get entity list for dslQuery {}"
,
dslQuery
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get entity list for dslQuery {}"
,
dslQuery
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -225,6 +228,9 @@ public class MetadataDiscoveryResource {
}
catch
(
DiscoveryException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to get entity list for gremlinQuery {}"
,
gremlinQuery
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get entity list for gremlinQuery {}"
,
gremlinQuery
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get entity list for gremlinQuery {}"
,
gremlinQuery
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -272,6 +278,9 @@ public class MetadataDiscoveryResource {
}
catch
(
DiscoveryException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to get entity list for query {}"
,
query
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get entity list for query {}"
,
query
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get entity list for query {}"
,
query
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java
View file @
b1717f2e
...
...
@@ -121,12 +121,12 @@ public class TypesResource {
return
Response
.
status
(
ClientResponse
.
Status
.
CREATED
).
entity
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Type creation failed"
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
e
.
getAtlasErrorCode
().
getHttpCode
()
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
));
}
catch
(
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to persist types"
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to persist types
due to V2 API error
"
,
e
);
LOG
.
error
(
"Unable to persist types"
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to persist types"
,
e
);
...
...
@@ -187,11 +187,14 @@ public class TypesResource {
response
.
put
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
response
.
put
(
AtlasClient
.
TYPES
,
typesResponse
);
return
Response
.
ok
().
entity
(
response
).
build
();
}
catch
(
AtlasBaseException
|
IllegalArgumentException
e
)
{
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to persist types"
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
));
}
catch
(
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to persist types"
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to persist types
due to V2 API error
"
,
e
);
LOG
.
error
(
"Unable to persist types"
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to persist types"
,
e
);
...
...
@@ -237,10 +240,13 @@ public class TypesResource {
return
Response
.
ok
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to get type definition for type {}"
,
typeName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
NOT_FOUND
));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
));
}
catch
(
JSONException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to get type definition for type {}"
,
typeName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get type definition for type {}"
,
typeName
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get type definition for type {}"
,
typeName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
@@ -292,7 +298,10 @@ public class TypesResource {
return
Response
.
ok
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
warn
(
"TypesREST exception: {} {}"
,
e
.
getClass
().
getSimpleName
(),
e
.
getMessage
());
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
e
.
getAtlasErrorCode
().
getHttpCode
()));
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
));
}
catch
(
WebApplicationException
e
)
{
LOG
.
error
(
"Unable to get types list"
,
e
);
throw
e
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Unable to get types list"
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
...
...
webapp/src/main/java/org/apache/atlas/web/util/Servlets.java
View file @
b1717f2e
...
...
@@ -20,6 +20,7 @@ package org.apache.atlas.web.util;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.LocalServletRequest
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.utils.ParamChecker
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.io.IOUtils
;
...
...
@@ -137,6 +138,13 @@ public final class Servlets {
return
url
.
toString
();
}
public
static
Response
getErrorResponse
(
AtlasBaseException
e
)
{
String
message
=
e
.
getMessage
()
==
null
?
"Failed with "
+
e
.
getClass
().
getName
()
:
e
.
getMessage
();
Response
response
=
getErrorResponse
(
message
,
e
.
getAtlasErrorCode
().
getHttpCode
());
return
response
;
}
public
static
Response
getErrorResponse
(
Throwable
e
,
Response
.
Status
status
)
{
String
message
=
e
.
getMessage
()
==
null
?
"Failed with "
+
e
.
getClass
().
getName
()
:
e
.
getMessage
();
Response
response
=
getErrorResponse
(
message
,
status
);
...
...
webapp/src/test/java/org/apache/atlas/examples/QuickStartV2IT.java
View file @
b1717f2e
...
...
@@ -28,6 +28,7 @@ import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
import
org.apache.atlas.model.lineage.AtlasLineageInfo.LineageRelation
;
import
org.apache.atlas.web.resources.BaseResourceIT
;
import
org.codehaus.jettison.json.JSONException
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
...
...
@@ -35,6 +36,7 @@ import java.util.ArrayList;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.UUID
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
...
...
@@ -98,13 +100,13 @@ public class QuickStartV2IT extends BaseResourceIT {
private
void
verifyColumnsAreAddedToTable
(
AtlasEntity
table
)
throws
JSONException
{
Map
<
String
,
Object
>
tableAttributes
=
table
.
getAttributes
();
List
<
AtlasEntity
>
columns
=
(
List
<
AtlasEntity
>)
tableAttributes
.
get
(
"columns"
);
List
<
Map
>
columns
=
(
List
<
Map
>)
tableAttributes
.
get
(
"columns"
);
assertEquals
(
4
,
columns
.
size
());
Map
<
String
,
Object
>
column
=
(
Map
)
columns
.
get
(
0
);
Map
<
String
,
Object
>
columnAttributes
=
(
Map
)
column
.
get
(
"attributes
"
);
assertEquals
(
QuickStartV2
.
TIME_ID_COLUMN
,
columnAttributes
.
get
(
"name"
));
assertEquals
(
"int"
,
columnAttributes
.
get
(
"dataType"
));
for
(
Map
colMap
:
columns
)
{
String
colGuid
=
(
String
)
colMap
.
get
(
"guid
"
);
assertNotNull
(
UUID
.
fromString
(
colGuid
));
}
}
private
void
verifyDBIsLinkedToTable
(
AtlasEntity
table
)
throws
AtlasServiceException
,
JSONException
{
...
...
webapp/src/test/java/org/apache/atlas/web/resources/EntityResourceTest.java
View file @
b1717f2e
...
...
@@ -69,8 +69,10 @@ public class EntityResourceTest {
EntityMutationResponse
resp
=
new
EntityMutationResponse
();
List
<
AtlasEntityHeader
>
headers
=
toAtlasEntityHeaders
(
guids
);
for
(
AtlasEntityHeader
entity
:
headers
)
{
resp
.
addEntity
(
EntityMutations
.
EntityOperation
.
DELETE
,
entity
);
if
(
CollectionUtils
.
isNotEmpty
(
headers
))
{
for
(
AtlasEntityHeader
entity
:
headers
)
{
resp
.
addEntity
(
EntityMutations
.
EntityOperation
.
DELETE
,
entity
);
}
}
when
(
entitiesStore
.
deleteByIds
(
guids
)).
thenReturn
(
resp
);
...
...
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