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
0fe4d885
Commit
0fe4d885
authored
8 years ago
by
apoorvnaik
Committed by
Madhan Neethiraj
8 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1534: TypesREST clean up for simpler REST interface
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
9cb56c54
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
159 additions
and
558 deletions
+159
-558
AtlasTypedefClientV2.java
.../src/main/java/org/apache/atlas/AtlasTypedefClientV2.java
+28
-4
AtlasErrorCode.java
intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
+5
-7
AtlasTypeDefStore.java
...c/main/java/org/apache/atlas/store/AtlasTypeDefStore.java
+11
-55
AtlasTypeDefGraphStore.java
.../atlas/repository/store/graph/AtlasTypeDefGraphStore.java
+50
-200
AtlasTypeDefGraphStoreTest.java
...as/repository/store/graph/AtlasTypeDefGraphStoreTest.java
+21
-32
AtlasEntityStoreV1Test.java
...las/repository/store/graph/v1/AtlasEntityStoreV1Test.java
+3
-1
TypesResource.java
...in/java/org/apache/atlas/web/resources/TypesResource.java
+1
-1
TypesREST.java
...pp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
+40
-258
No files found.
client/src/main/java/org/apache/atlas/AtlasTypedefClientV2.java
View file @
0fe4d885
...
@@ -117,21 +117,45 @@ public class AtlasTypedefClientV2 extends AtlasBaseClient {
...
@@ -117,21 +117,45 @@ public class AtlasTypedefClientV2 extends AtlasBaseClient {
return
getTypeDefByGuid
(
guid
,
AtlasEntityDef
.
class
);
return
getTypeDefByGuid
(
guid
,
AtlasEntityDef
.
class
);
}
}
@Deprecated
public
AtlasEnumDef
createEnumDef
(
AtlasEnumDef
enumDef
)
throws
AtlasServiceException
{
public
AtlasEnumDef
createEnumDef
(
AtlasEnumDef
enumDef
)
throws
AtlasServiceException
{
return
callAPI
(
CREATE_ENUM_DEF
,
AtlasType
.
toJson
(
enumDef
),
AtlasEnumDef
.
class
);
AtlasTypesDef
atlasTypesDef
=
new
AtlasTypesDef
();
atlasTypesDef
.
getEnumDefs
().
add
(
enumDef
);
AtlasTypesDef
created
=
createAtlasTypeDefs
(
atlasTypesDef
);
assert
created
!=
null
;
assert
created
.
getEnumDefs
()
!=
null
;
return
created
.
getEnumDefs
().
get
(
0
);
}
}
@Deprecated
public
AtlasStructDef
createStructDef
(
AtlasStructDef
structDef
)
throws
AtlasServiceException
{
public
AtlasStructDef
createStructDef
(
AtlasStructDef
structDef
)
throws
AtlasServiceException
{
return
callAPI
(
CREATE_STRUCT_DEF
,
AtlasType
.
toJson
(
structDef
),
AtlasStructDef
.
class
);
AtlasTypesDef
atlasTypesDef
=
new
AtlasTypesDef
();
atlasTypesDef
.
getStructDefs
().
add
(
structDef
);
AtlasTypesDef
created
=
createAtlasTypeDefs
(
atlasTypesDef
);
assert
created
!=
null
;
assert
created
.
getStructDefs
()
!=
null
;
return
created
.
getStructDefs
().
get
(
0
);
}
}
@Deprecated
public
AtlasEntityDef
createEntityDef
(
AtlasEntityDef
entityDef
)
throws
AtlasServiceException
{
public
AtlasEntityDef
createEntityDef
(
AtlasEntityDef
entityDef
)
throws
AtlasServiceException
{
return
callAPI
(
CREATE_ENTITY_DEF
,
AtlasType
.
toJson
(
entityDef
),
AtlasEntityDef
.
class
);
AtlasTypesDef
atlasTypesDef
=
new
AtlasTypesDef
();
atlasTypesDef
.
getEntityDefs
().
add
(
entityDef
);
AtlasTypesDef
created
=
createAtlasTypeDefs
(
atlasTypesDef
);
assert
created
!=
null
;
assert
created
.
getEntityDefs
()
!=
null
;
return
created
.
getEntityDefs
().
get
(
0
);
}
}
@Deprecated
public
AtlasClassificationDef
createClassificationDef
(
AtlasClassificationDef
classificationDef
)
public
AtlasClassificationDef
createClassificationDef
(
AtlasClassificationDef
classificationDef
)
throws
AtlasServiceException
{
throws
AtlasServiceException
{
return
callAPI
(
CREATE_CLASSIFICATION_DEF
,
AtlasType
.
toJson
(
classificationDef
),
AtlasClassificationDef
.
class
);
AtlasTypesDef
atlasTypesDef
=
new
AtlasTypesDef
();
atlasTypesDef
.
getClassificationDefs
().
add
(
classificationDef
);
AtlasTypesDef
created
=
createAtlasTypeDefs
(
atlasTypesDef
);
assert
created
!=
null
;
assert
created
.
getClassificationDefs
()
!=
null
;
return
created
.
getClassificationDefs
().
get
(
0
);
}
}
...
...
This diff is collapsed.
Click to expand it.
intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
View file @
0fe4d885
...
@@ -61,6 +61,9 @@ public enum AtlasErrorCode {
...
@@ -61,6 +61,9 @@ public enum AtlasErrorCode {
CONSTRAINT_OWNED_REF_ATTRIBUTE_INVALID_TYPE
(
400
,
"ATLAS40030E"
,
"{0}.{1}: invalid {2} constraint. Attribute {3} is not an entity type"
),
CONSTRAINT_OWNED_REF_ATTRIBUTE_INVALID_TYPE
(
400
,
"ATLAS40030E"
,
"{0}.{1}: invalid {2} constraint. Attribute {3} is not an entity type"
),
CANNOT_MAP_ATTRIBUTE
(
400
,
"ATLAS40031E"
,
"cannot map attribute: {0} of type: {1} from vertex"
),
CANNOT_MAP_ATTRIBUTE
(
400
,
"ATLAS40031E"
,
"cannot map attribute: {0} of type: {1} from vertex"
),
INVALID_OBJECT_ID
(
400
,
"ATLAS40032E"
,
"ObjectId is not valid {0}"
),
INVALID_OBJECT_ID
(
400
,
"ATLAS40032E"
,
"ObjectId is not valid {0}"
),
UNRESOLVED_REFERENCES_FOUND
(
400
,
"ATLAS40033E"
,
"Unresolved references: byId={0}; byUniqueAttributes={1}"
),
UNKNOWN_ATTRIBUTE
(
400
,
"ATLAS40034E"
,
"Attribute {0} not found for type {1}"
),
SYSTEM_TYPE
(
400
,
"ATLAS40035E"
,
"{0} is a System-type"
),
// All Not found enums go here
// All Not found enums go here
TYPE_NAME_NOT_FOUND
(
404
,
"ATLAS4041E"
,
"Given typename {0} was invalid"
),
TYPE_NAME_NOT_FOUND
(
404
,
"ATLAS4041E"
,
"Given typename {0} was invalid"
),
...
@@ -71,6 +74,7 @@ public enum AtlasErrorCode {
...
@@ -71,6 +74,7 @@ public enum AtlasErrorCode {
INSTANCE_LINEAGE_QUERY_FAILED
(
404
,
"ATLAS4047E"
,
"Instance lineage query failed {0}"
),
INSTANCE_LINEAGE_QUERY_FAILED
(
404
,
"ATLAS4047E"
,
"Instance lineage query failed {0}"
),
DISCOVERY_QUERY_FAILED
(
404
,
"ATLAS4048E"
,
"Discovery query failed {0}"
),
DISCOVERY_QUERY_FAILED
(
404
,
"ATLAS4048E"
,
"Discovery query failed {0}"
),
INSTANCE_CRUD_INVALID_PARAMS
(
404
,
"ATLAS4049E"
,
"Invalid instance creation/updation parameters passed : {0}"
),
INSTANCE_CRUD_INVALID_PARAMS
(
404
,
"ATLAS4049E"
,
"Invalid instance creation/updation parameters passed : {0}"
),
INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND
(
404
,
"ATLAS40410E"
,
"Instance {0} with unique attribute {1}={2} does not exist"
),
// All data conflict errors go here
// All data conflict errors go here
...
@@ -82,13 +86,7 @@ public enum AtlasErrorCode {
...
@@ -82,13 +86,7 @@ public enum AtlasErrorCode {
INTERNAL_ERROR
(
500
,
"ATLAS5001E"
,
"Internal server error {0}"
),
INTERNAL_ERROR
(
500
,
"ATLAS5001E"
,
"Internal server error {0}"
),
INDEX_CREATION_FAILED
(
500
,
"ATLAS5002E"
,
"Index creation failed for {0}"
),
INDEX_CREATION_FAILED
(
500
,
"ATLAS5002E"
,
"Index creation failed for {0}"
),
INDEX_ROLLBACK_FAILED
(
500
,
"ATLAS5003E"
,
"Index rollback failed for {0}"
),
INDEX_ROLLBACK_FAILED
(
500
,
"ATLAS5003E"
,
"Index rollback failed for {0}"
),
FAILED_TO_OBTAIN_TYPE_UPDATE_LOCK
(
500
,
"ATLAS5004E"
,
"Failed to get the lock; another type update might be in progress. Please try again"
),
FAILED_TO_OBTAIN_TYPE_UPDATE_LOCK
(
500
,
"ATLAS5004E"
,
"Failed to get the lock; another type update might be in progress. Please try again"
);
INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND
(
400
,
"ATLAS40018E"
,
"Instance {0} with unique attribute {1}={2} does not exist"
),
UNRESOLVED_REFERENCES_FOUND
(
400
,
"ATLAS40010E"
,
"Unresolved references: byId={0}; byUniqueAttributes={1}"
),
UNKNOWN_ATTRIBUTE
(
400
,
"ATLAS40019E"
,
"Attribute {0} not found for type {1}"
);
private
String
errorCode
;
private
String
errorCode
;
private
String
errorMessage
;
private
String
errorMessage
;
...
...
This diff is collapsed.
Click to expand it.
intg/src/main/java/org/apache/atlas/store/AtlasTypeDefStore.java
View file @
0fe4d885
...
@@ -19,14 +19,12 @@ package org.apache.atlas.store;
...
@@ -19,14 +19,12 @@ package org.apache.atlas.store;
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.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.AtlasClassificationDef.AtlasClassificationDefs
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.model.typedef.AtlasEntityDef.AtlasEntityDefs
;
import
org.apache.atlas.model.typedef.AtlasEnumDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumDefs
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasStructDefs
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
java.util.List
;
import
java.util.List
;
...
@@ -37,13 +35,7 @@ import java.util.List;
...
@@ -37,13 +35,7 @@ import java.util.List;
public
interface
AtlasTypeDefStore
{
public
interface
AtlasTypeDefStore
{
void
init
()
throws
AtlasBaseException
;
void
init
()
throws
AtlasBaseException
;
/***********************/
/* EnumDef operations */
/** EnumDef operation **/
/***********************/
AtlasEnumDef
createEnumDef
(
AtlasEnumDef
enumDef
)
throws
AtlasBaseException
;
List
<
AtlasEnumDef
>
getAllEnumDefs
()
throws
AtlasBaseException
;
AtlasEnumDef
getEnumDefByName
(
String
name
)
throws
AtlasBaseException
;
AtlasEnumDef
getEnumDefByName
(
String
name
)
throws
AtlasBaseException
;
...
@@ -53,18 +45,7 @@ public interface AtlasTypeDefStore {
...
@@ -53,18 +45,7 @@ public interface AtlasTypeDefStore {
AtlasEnumDef
updateEnumDefByGuid
(
String
guid
,
AtlasEnumDef
enumDef
)
throws
AtlasBaseException
;
AtlasEnumDef
updateEnumDefByGuid
(
String
guid
,
AtlasEnumDef
enumDef
)
throws
AtlasBaseException
;
void
deleteEnumDefByName
(
String
name
)
throws
AtlasBaseException
;
/* StructDef operations */
void
deleteEnumDefByGuid
(
String
guid
)
throws
AtlasBaseException
;
AtlasEnumDefs
searchEnumDefs
(
SearchFilter
filter
)
throws
AtlasBaseException
;
/*************************/
/** StructDef operation **/
/*************************/
AtlasStructDef
createStructDef
(
AtlasStructDef
structDef
)
throws
AtlasBaseException
;
List
<
AtlasStructDef
>
getAllStructDefs
()
throws
AtlasBaseException
;
AtlasStructDef
getStructDefByName
(
String
name
)
throws
AtlasBaseException
;
AtlasStructDef
getStructDefByName
(
String
name
)
throws
AtlasBaseException
;
...
@@ -74,19 +55,7 @@ public interface AtlasTypeDefStore {
...
@@ -74,19 +55,7 @@ public interface AtlasTypeDefStore {
AtlasStructDef
updateStructDefByGuid
(
String
guid
,
AtlasStructDef
structDef
)
throws
AtlasBaseException
;
AtlasStructDef
updateStructDefByGuid
(
String
guid
,
AtlasStructDef
structDef
)
throws
AtlasBaseException
;
void
deleteStructDefByName
(
String
name
)
throws
AtlasBaseException
;
/* ClassificationDef operations */
void
deleteStructDefByGuid
(
String
guid
)
throws
AtlasBaseException
;
AtlasStructDefs
searchStructDefs
(
SearchFilter
filter
)
throws
AtlasBaseException
;
/*********************************/
/** ClassificationDef operation **/
/*********************************/
AtlasClassificationDef
createClassificationDef
(
AtlasClassificationDef
classificationDef
)
throws
AtlasBaseException
;
List
<
AtlasClassificationDef
>
getAllClassificationDefs
()
throws
AtlasBaseException
;
AtlasClassificationDef
getClassificationDefByName
(
String
name
)
throws
AtlasBaseException
;
AtlasClassificationDef
getClassificationDefByName
(
String
name
)
throws
AtlasBaseException
;
...
@@ -98,19 +67,7 @@ public interface AtlasTypeDefStore {
...
@@ -98,19 +67,7 @@ public interface AtlasTypeDefStore {
AtlasClassificationDef
updateClassificationDefByGuid
(
String
guid
,
AtlasClassificationDef
classificationDef
)
AtlasClassificationDef
updateClassificationDefByGuid
(
String
guid
,
AtlasClassificationDef
classificationDef
)
throws
AtlasBaseException
;
throws
AtlasBaseException
;
void
deleteClassificationDefByName
(
String
name
)
throws
AtlasBaseException
;
/* EntityDef operations */
void
deleteClassificationDefByGuid
(
String
guid
)
throws
AtlasBaseException
;
AtlasClassificationDefs
searchClassificationDefs
(
SearchFilter
filter
)
throws
AtlasBaseException
;
/*************************/
/** EntityDef operation **/
/*************************/
AtlasEntityDef
createEntityDef
(
AtlasEntityDef
entityDef
)
throws
AtlasBaseException
;
List
<
AtlasEntityDef
>
getAllEntityDefs
()
throws
AtlasBaseException
;
AtlasEntityDef
getEntityDefByName
(
String
name
)
throws
AtlasBaseException
;
AtlasEntityDef
getEntityDefByName
(
String
name
)
throws
AtlasBaseException
;
...
@@ -120,13 +77,7 @@ public interface AtlasTypeDefStore {
...
@@ -120,13 +77,7 @@ public interface AtlasTypeDefStore {
AtlasEntityDef
updateEntityDefByGuid
(
String
guid
,
AtlasEntityDef
entityDef
)
throws
AtlasBaseException
;
AtlasEntityDef
updateEntityDefByGuid
(
String
guid
,
AtlasEntityDef
entityDef
)
throws
AtlasBaseException
;
void
deleteEntityDefByName
(
String
name
)
throws
AtlasBaseException
;
/* Bulk Operations */
void
deleteEntityDefByGuid
(
String
guid
)
throws
AtlasBaseException
;
AtlasEntityDefs
searchEntityDefs
(
SearchFilter
filter
)
throws
AtlasBaseException
;
/***** Bulk Operations *****/
AtlasTypesDef
createTypesDef
(
AtlasTypesDef
atlasTypesDef
)
throws
AtlasBaseException
;
AtlasTypesDef
createTypesDef
(
AtlasTypesDef
atlasTypesDef
)
throws
AtlasBaseException
;
...
@@ -135,4 +86,9 @@ public interface AtlasTypeDefStore {
...
@@ -135,4 +86,9 @@ public interface AtlasTypeDefStore {
void
deleteTypesDef
(
AtlasTypesDef
atlasTypesDef
)
throws
AtlasBaseException
;
void
deleteTypesDef
(
AtlasTypesDef
atlasTypesDef
)
throws
AtlasBaseException
;
AtlasTypesDef
searchTypesDef
(
SearchFilter
searchFilter
)
throws
AtlasBaseException
;
AtlasTypesDef
searchTypesDef
(
SearchFilter
searchFilter
)
throws
AtlasBaseException
;
/* Generic operation */
AtlasBaseTypeDef
getByName
(
String
name
)
throws
AtlasBaseException
;
AtlasBaseTypeDef
getByGuid
(
String
guid
)
throws
AtlasBaseException
;
}
}
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
View file @
0fe4d885
...
@@ -26,23 +26,23 @@ import org.apache.atlas.listener.ActiveStateChangeHandler;
...
@@ -26,23 +26,23 @@ import org.apache.atlas.listener.ActiveStateChangeHandler;
import
org.apache.atlas.listener.ChangedTypeDefs
;
import
org.apache.atlas.listener.ChangedTypeDefs
;
import
org.apache.atlas.listener.TypeDefChangeListener
;
import
org.apache.atlas.listener.TypeDefChangeListener
;
import
org.apache.atlas.model.SearchFilter
;
import
org.apache.atlas.model.SearchFilter
;
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.AtlasEntityDef.AtlasEntityDefs
;
import
org.apache.atlas.model.typedef.AtlasEnumDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumDefs
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasStructDefs
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer
;
import
org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer
;
import
org.apache.atlas.repository.util.FilterUtil
;
import
org.apache.atlas.repository.util.FilterUtil
;
import
org.apache.atlas.store.AtlasTypeDefStore
;
import
org.apache.atlas.store.AtlasTypeDefStore
;
import
org.apache.atlas.type.AtlasClassificationType
;
import
org.apache.atlas.type.AtlasClassificationType
;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.type.AtlasEnumType
;
import
org.apache.atlas.type.AtlasStructType
;
import
org.apache.atlas.type.AtlasStructType
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeUtil
;
import
org.apache.atlas.util.AtlasRepositoryConfiguration
;
import
org.apache.atlas.util.AtlasRepositoryConfiguration
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.Predicate
;
import
org.apache.commons.collections.Predicate
;
...
@@ -54,7 +54,6 @@ import org.slf4j.LoggerFactory;
...
@@ -54,7 +54,6 @@ import org.slf4j.LoggerFactory;
import
java.io.File
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -110,28 +109,6 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
...
@@ -110,28 +109,6 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
@Override
@Override
@GraphTransaction
@GraphTransaction
public
AtlasEnumDef
createEnumDef
(
AtlasEnumDef
enumDef
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
ttr
.
addType
(
enumDef
);
AtlasEnumDef
ret
=
getEnumDefStore
(
ttr
).
create
(
enumDef
);
ttr
.
updateGuid
(
ret
.
getName
(),
ret
.
getGuid
());
return
ret
;
}
@Override
@GraphTransaction
public
List
<
AtlasEnumDef
>
getAllEnumDefs
()
throws
AtlasBaseException
{
Collection
<
AtlasEnumDef
>
enumDefs
=
typeRegistry
.
getAllEnumDefs
();
return
CollectionUtils
.
isNotEmpty
(
enumDefs
)
?
new
ArrayList
<>(
enumDefs
)
:
Collections
.<
AtlasEnumDef
>
emptyList
();
}
@Override
@GraphTransaction
public
AtlasEnumDef
getEnumDefByName
(
String
name
)
throws
AtlasBaseException
{
public
AtlasEnumDef
getEnumDefByName
(
String
name
)
throws
AtlasBaseException
{
AtlasEnumDef
ret
=
typeRegistry
.
getEnumDefByName
(
name
);
AtlasEnumDef
ret
=
typeRegistry
.
getEnumDefByName
(
name
);
if
(
ret
==
null
)
{
if
(
ret
==
null
)
{
...
@@ -172,54 +149,6 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
...
@@ -172,54 +149,6 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
@Override
@Override
@GraphTransaction
@GraphTransaction
public
void
deleteEnumDefByName
(
String
name
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
ttr
.
removeTypeByName
(
name
);
getEnumDefStore
(
ttr
).
deleteByName
(
name
);
}
@Override
@GraphTransaction
public
void
deleteEnumDefByGuid
(
String
guid
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
ttr
.
removeTypeByGuid
(
guid
);
getEnumDefStore
(
ttr
).
deleteByGuid
(
guid
);
}
@Override
@GraphTransaction
public
AtlasEnumDefs
searchEnumDefs
(
SearchFilter
filter
)
throws
AtlasBaseException
{
return
getEnumDefStore
(
typeRegistry
).
search
(
filter
);
}
@Override
@GraphTransaction
public
AtlasStructDef
createStructDef
(
AtlasStructDef
structDef
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
ttr
.
addType
(
structDef
);
AtlasStructDef
ret
=
getStructDefStore
(
ttr
).
create
(
structDef
,
null
);
ttr
.
updateGuid
(
ret
.
getName
(),
ret
.
getGuid
());
return
ret
;
}
@Override
@GraphTransaction
public
List
<
AtlasStructDef
>
getAllStructDefs
()
throws
AtlasBaseException
{
Collection
<
AtlasStructDef
>
structDefs
=
typeRegistry
.
getAllStructDefs
();
return
CollectionUtils
.
isNotEmpty
(
structDefs
)
?
new
ArrayList
<>(
structDefs
)
:
Collections
.<
AtlasStructDef
>
emptyList
();
}
@Override
@GraphTransaction
public
AtlasStructDef
getStructDefByName
(
String
name
)
throws
AtlasBaseException
{
public
AtlasStructDef
getStructDefByName
(
String
name
)
throws
AtlasBaseException
{
AtlasStructDef
ret
=
typeRegistry
.
getStructDefByName
(
name
);
AtlasStructDef
ret
=
typeRegistry
.
getStructDefByName
(
name
);
...
@@ -264,56 +193,6 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
...
@@ -264,56 +193,6 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
@Override
@Override
@GraphTransaction
@GraphTransaction
public
void
deleteStructDefByName
(
String
name
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
ttr
.
removeTypeByName
(
name
);
getStructDefStore
(
ttr
).
deleteByName
(
name
,
null
);
}
@Override
@GraphTransaction
public
void
deleteStructDefByGuid
(
String
guid
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
ttr
.
removeTypeByGuid
(
guid
);
getStructDefStore
(
ttr
).
deleteByGuid
(
guid
,
null
);
}
@Override
@GraphTransaction
public
AtlasStructDefs
searchStructDefs
(
SearchFilter
filter
)
throws
AtlasBaseException
{
return
getStructDefStore
(
typeRegistry
).
search
(
filter
);
}
@Override
@GraphTransaction
public
AtlasClassificationDef
createClassificationDef
(
AtlasClassificationDef
classificationDef
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
ttr
.
addType
(
classificationDef
);
AtlasClassificationDef
ret
=
getClassificationDefStore
(
ttr
).
create
(
classificationDef
,
null
);
ttr
.
updateGuid
(
ret
.
getName
(),
ret
.
getGuid
());
return
ret
;
}
@Override
@GraphTransaction
public
List
<
AtlasClassificationDef
>
getAllClassificationDefs
()
throws
AtlasBaseException
{
Collection
<
AtlasClassificationDef
>
classificationDefs
=
typeRegistry
.
getAllClassificationDefs
();
return
CollectionUtils
.
isNotEmpty
(
classificationDefs
)
?
new
ArrayList
<>(
classificationDefs
)
:
Collections
.<
AtlasClassificationDef
>
emptyList
();
}
@Override
@GraphTransaction
public
AtlasClassificationDef
getClassificationDefByName
(
String
name
)
throws
AtlasBaseException
{
public
AtlasClassificationDef
getClassificationDefByName
(
String
name
)
throws
AtlasBaseException
{
AtlasClassificationDef
ret
=
typeRegistry
.
getClassificationDefByName
(
name
);
AtlasClassificationDef
ret
=
typeRegistry
.
getClassificationDefByName
(
name
);
...
@@ -360,54 +239,6 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
...
@@ -360,54 +239,6 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
@Override
@Override
@GraphTransaction
@GraphTransaction
public
void
deleteClassificationDefByName
(
String
name
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
ttr
.
removeTypeByName
(
name
);
getClassificationDefStore
(
ttr
).
deleteByName
(
name
,
null
);
}
@Override
@GraphTransaction
public
void
deleteClassificationDefByGuid
(
String
guid
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
ttr
.
removeTypeByGuid
(
guid
);
getClassificationDefStore
(
ttr
).
deleteByGuid
(
guid
,
null
);
}
@Override
@GraphTransaction
public
AtlasClassificationDefs
searchClassificationDefs
(
SearchFilter
filter
)
throws
AtlasBaseException
{
return
getClassificationDefStore
(
typeRegistry
).
search
(
filter
);
}
@Override
@GraphTransaction
public
AtlasEntityDef
createEntityDef
(
AtlasEntityDef
entityDef
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
ttr
.
addType
(
entityDef
);
AtlasEntityDef
ret
=
getEntityDefStore
(
ttr
).
create
(
entityDef
,
null
);
ttr
.
updateGuid
(
ret
.
getName
(),
ret
.
getGuid
());
return
ret
;
}
@Override
@GraphTransaction
public
List
<
AtlasEntityDef
>
getAllEntityDefs
()
throws
AtlasBaseException
{
Collection
<
AtlasEntityDef
>
entityDefs
=
typeRegistry
.
getAllEntityDefs
();
return
CollectionUtils
.
isNotEmpty
(
entityDefs
)
?
new
ArrayList
<>(
entityDefs
)
:
Collections
.<
AtlasEntityDef
>
emptyList
();
}
@Override
@GraphTransaction
public
AtlasEntityDef
getEntityDefByName
(
String
name
)
throws
AtlasBaseException
{
public
AtlasEntityDef
getEntityDefByName
(
String
name
)
throws
AtlasBaseException
{
AtlasEntityDef
ret
=
typeRegistry
.
getEntityDefByName
(
name
);
AtlasEntityDef
ret
=
typeRegistry
.
getEntityDefByName
(
name
);
...
@@ -452,35 +283,9 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
...
@@ -452,35 +283,9 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
@Override
@Override
@GraphTransaction
@GraphTransaction
public
void
deleteEntityDefByName
(
String
name
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
ttr
.
removeTypeByName
(
name
);
getEntityDefStore
(
ttr
).
deleteByName
(
name
,
null
);
}
@Override
@GraphTransaction
public
void
deleteEntityDefByGuid
(
String
guid
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
ttr
.
removeTypeByGuid
(
guid
);
getEntityDefStore
(
ttr
).
deleteByGuid
(
guid
,
null
);
}
@Override
@GraphTransaction
public
AtlasEntityDefs
searchEntityDefs
(
SearchFilter
filter
)
throws
AtlasBaseException
{
return
getEntityDefStore
(
typeRegistry
).
search
(
filter
);
}
@Override
@GraphTransaction
public
AtlasTypesDef
createTypesDef
(
AtlasTypesDef
typesDef
)
throws
AtlasBaseException
{
public
AtlasTypesDef
createTypesDef
(
AtlasTypesDef
typesDef
)
throws
AtlasBaseException
{
if
(
LOG
.
isDebugEnabled
())
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> AtlasTypeDefGraphStore.createTypesDef(enums={}, structs={}, classfications={}, entities={})"
,
LOG
.
debug
(
"==> AtlasTypeDefGraphStore.createTypesDef(enums={}, structs={}, class
i
fications={}, entities={})"
,
CollectionUtils
.
size
(
typesDef
.
getEnumDefs
()),
CollectionUtils
.
size
(
typesDef
.
getEnumDefs
()),
CollectionUtils
.
size
(
typesDef
.
getStructDefs
()),
CollectionUtils
.
size
(
typesDef
.
getStructDefs
()),
CollectionUtils
.
size
(
typesDef
.
getClassificationDefs
()),
CollectionUtils
.
size
(
typesDef
.
getClassificationDefs
()),
...
@@ -826,6 +631,26 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
...
@@ -826,6 +631,26 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
}
}
@Override
@Override
@GraphTransaction
public
AtlasBaseTypeDef
getByName
(
String
name
)
throws
AtlasBaseException
{
if
(
StringUtils
.
isBlank
(
name
))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
TYPE_NAME_INVALID
,
""
,
name
);
}
AtlasType
type
=
typeRegistry
.
getType
(
name
);
return
getTypeDefFromType
(
type
);
}
@Override
@GraphTransaction
public
AtlasBaseTypeDef
getByGuid
(
String
guid
)
throws
AtlasBaseException
{
if
(
StringUtils
.
isBlank
(
guid
))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
TYPE_GUID_NOT_FOUND
,
guid
);
}
AtlasType
type
=
typeRegistry
.
getTypeByGuid
(
guid
);
return
getTypeDefFromType
(
type
);
}
@Override
public
void
instanceIsActive
()
throws
AtlasException
{
public
void
instanceIsActive
()
throws
AtlasException
{
try
{
try
{
init
();
init
();
...
@@ -848,6 +673,31 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
...
@@ -848,6 +673,31 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
storeInitializer
.
initializeStore
(
this
,
typeRegistry
,
typesDirName
);
storeInitializer
.
initializeStore
(
this
,
typeRegistry
,
typesDirName
);
}
}
private
AtlasBaseTypeDef
getTypeDefFromType
(
AtlasType
type
)
throws
AtlasBaseException
{
AtlasBaseTypeDef
ret
;
switch
(
type
.
getTypeCategory
())
{
case
ENUM:
ret
=
((
AtlasEnumType
)
type
).
getEnumDef
();
break
;
case
STRUCT:
ret
=
((
AtlasStructType
)
type
).
getStructDef
();
break
;
case
CLASSIFICATION:
ret
=
((
AtlasClassificationType
)
type
).
getClassificationDef
();
break
;
case
ENTITY:
ret
=
((
AtlasEntityType
)
type
).
getEntityDef
();
break
;
case
PRIMITIVE:
case
OBJECT_ID_TYPE:
case
ARRAY:
case
MAP:
default
:
throw
new
AtlasBaseException
(
AtlasErrorCode
.
SYSTEM_TYPE
,
type
.
getTypeCategory
().
name
());
}
return
ret
;
}
private
AtlasTransientTypeRegistry
lockTypeRegistryAndReleasePostCommit
()
throws
AtlasBaseException
{
private
AtlasTransientTypeRegistry
lockTypeRegistryAndReleasePostCommit
()
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
typeRegistry
.
lockTypeRegistryForUpdate
(
typeUpdateLockMaxWaitTimeSeconds
);
AtlasTransientTypeRegistry
ttr
=
typeRegistry
.
lockTypeRegistryForUpdate
(
typeUpdateLockMaxWaitTimeSeconds
);
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
View file @
0fe4d885
...
@@ -38,6 +38,7 @@ import org.testng.annotations.DataProvider;
...
@@ -38,6 +38,7 @@ import org.testng.annotations.DataProvider;
import
org.testng.annotations.Guice
;
import
org.testng.annotations.Guice
;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
...
@@ -64,36 +65,16 @@ public class AtlasTypeDefGraphStoreTest {
...
@@ -64,36 +65,16 @@ public class AtlasTypeDefGraphStoreTest {
@Test
(
priority
=
1
)
@Test
(
priority
=
1
)
public
void
testGet
()
{
public
void
testGet
()
{
try
{
try
{
List
<
AtlasEnumDef
>
allEnumDefs
=
typeDefStore
.
getAllEnumDefs
();
AtlasTypesDef
typesDef
=
typeDefStore
.
searchTypesDef
(
new
SearchFilter
());
assertNotNull
(
allEnumDefs
);
assertNotNull
(
typesDef
.
getEnumDefs
());
assertEquals
(
allEnumDefs
.
size
(),
0
);
assertEquals
(
typesDef
.
getStructDefs
().
size
(),
0
);
}
catch
(
AtlasBaseException
e
)
{
assertNotNull
(
typesDef
.
getStructDefs
());
fail
(
"Get should've succeeded"
,
e
);
assertEquals
(
typesDef
.
getClassificationDefs
().
size
(),
0
);
}
assertNotNull
(
typesDef
.
getClassificationDefs
());
assertEquals
(
typesDef
.
getEntityDefs
().
size
(),
0
);
try
{
assertNotNull
(
typesDef
.
getEntityDefs
());
List
<
AtlasClassificationDef
>
allClassificationDefs
=
typeDefStore
.
getAllClassificationDefs
();
assertNotNull
(
allClassificationDefs
);
assertEquals
(
allClassificationDefs
.
size
(),
0
);
}
catch
(
AtlasBaseException
e
)
{
fail
(
"Get should've succeeded"
,
e
);
}
try
{
List
<
AtlasStructDef
>
allStructDefs
=
typeDefStore
.
getAllStructDefs
();
assertNotNull
(
allStructDefs
);
assertEquals
(
allStructDefs
.
size
(),
0
);
}
catch
(
AtlasBaseException
e
)
{
fail
(
"Get should've succeeded"
,
e
);
}
try
{
List
<
AtlasEntityDef
>
allEntityDefs
=
typeDefStore
.
getAllEntityDefs
();
assertNotNull
(
allEntityDefs
);
// For some reason this keeps on toggling b/w 0 and 5, need to investigate
assertTrue
(
allEntityDefs
.
size
()>=
0
);
}
catch
(
AtlasBaseException
e
)
{
}
catch
(
AtlasBaseException
e
)
{
fail
(
"
Get should've succeeded"
,
e
);
fail
(
"
Search of types shouldn't have failed"
);
}
}
}
}
...
@@ -385,17 +366,25 @@ public class AtlasTypeDefGraphStoreTest {
...
@@ -385,17 +366,25 @@ public class AtlasTypeDefGraphStoreTest {
@Test
(
dependsOnMethods
=
"testGet"
)
@Test
(
dependsOnMethods
=
"testGet"
)
public
void
testCreateWithInvalidSuperTypes
(){
public
void
testCreateWithInvalidSuperTypes
(){
AtlasTypesDef
typesDef
;
// Test Classification with supertype
// Test Classification with supertype
AtlasClassificationDef
classificationDef
=
TestUtilsV2
.
getClassificationWithInvalidSuperType
();
AtlasClassificationDef
classificationDef
=
TestUtilsV2
.
getClassificationWithInvalidSuperType
();
typesDef
=
new
AtlasTypesDef
();
typesDef
.
getClassificationDefs
().
add
(
classificationDef
);
try
{
try
{
Atlas
ClassificationDef
created
=
typeDefStore
.
createClassificationDef
(
classification
Def
);
Atlas
TypesDef
created
=
typeDefStore
.
createTypesDef
(
types
Def
);
fail
(
"Classification creation with invalid supertype should've failed"
);
fail
(
"Classification creation with invalid supertype should've failed"
);
}
catch
(
AtlasBaseException
e
)
{}
}
catch
(
AtlasBaseException
e
)
{
typesDef
=
null
;
}
// Test Entity with supertype
// Test Entity with supertype
AtlasEntityDef
entityDef
=
TestUtilsV2
.
getEntityWithInvalidSuperType
();
AtlasEntityDef
entityDef
=
TestUtilsV2
.
getEntityWithInvalidSuperType
();
typesDef
=
new
AtlasTypesDef
();
typesDef
.
getEntityDefs
().
add
(
entityDef
);
try
{
try
{
Atlas
EntityDef
created
=
typeDefStore
.
createEntityDef
(
entity
Def
);
Atlas
TypesDef
created
=
typeDefStore
.
createTypesDef
(
types
Def
);
fail
(
"Entity creation with invalid supertype should've failed"
);
fail
(
"Entity creation with invalid supertype should've failed"
);
}
catch
(
AtlasBaseException
e
)
{}
}
catch
(
AtlasBaseException
e
)
{}
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
View file @
0fe4d885
...
@@ -64,6 +64,7 @@ import org.testng.annotations.Test;
...
@@ -64,6 +64,7 @@ import org.testng.annotations.Test;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.Constructor
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -737,7 +738,8 @@ public class AtlasEntityStoreV1Test {
...
@@ -737,7 +738,8 @@ public class AtlasEntityStoreV1Test {
AtlasTypeUtil
.
createOptionalAttrDef
(
arrayAttrName
,
"array<string>"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
arrayAttrName
,
"array<string>"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
mapAttrName
,
"map<string,string>"
));
AtlasTypeUtil
.
createOptionalAttrDef
(
mapAttrName
,
"map<string,string>"
));
typeDefStore
.
createEntityDef
(
typeDefinition
);
AtlasTypesDef
atlasTypesDef
=
new
AtlasTypesDef
(
null
,
null
,
null
,
Arrays
.
asList
(
typeDefinition
));
typeDefStore
.
createTypesDef
(
atlasTypesDef
);
//verify that entity can be created with reserved characters in string value, array value and map key and value
//verify that entity can be created with reserved characters in string value, array value and map key and value
Map
<
String
,
AtlasEntity
>
entityCloneMap
=
new
HashMap
<>();
Map
<
String
,
AtlasEntity
>
entityCloneMap
=
new
HashMap
<>();
...
...
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java
View file @
0fe4d885
...
@@ -283,7 +283,7 @@ public class TypesResource {
...
@@ -283,7 +283,7 @@ public class TypesResource {
TypesREST
typesRest
=
resourceContext
.
getResource
(
TypesREST
.
class
);
TypesREST
typesRest
=
resourceContext
.
getResource
(
TypesREST
.
class
);
JSONObject
response
=
new
JSONObject
();
JSONObject
response
=
new
JSONObject
();
try
{
try
{
List
<
String
>
result
=
RestUtils
.
getTypeNames
(
typesRest
.
getTypeDefHeaders
());
List
<
String
>
result
=
RestUtils
.
getTypeNames
(
typesRest
.
getTypeDefHeaders
(
request
));
response
.
put
(
AtlasClient
.
RESULTS
,
new
JSONArray
(
result
));
response
.
put
(
AtlasClient
.
RESULTS
,
new
JSONArray
(
result
));
response
.
put
(
AtlasClient
.
COUNT
,
result
.
size
());
response
.
put
(
AtlasClient
.
COUNT
,
result
.
size
());
...
...
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
View file @
0fe4d885
...
@@ -20,14 +20,13 @@ package org.apache.atlas.web.rest;
...
@@ -20,14 +20,13 @@ 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.AtlasClassificationDef
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef.AtlasClassificationDefs
;
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.AtlasEntityDef.AtlasEntityDefs
;
import
org.apache.atlas.model.typedef.AtlasEnumDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumDefs
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasStructDefs
;
import
org.apache.atlas.model.typedef.AtlasTypeDefHeader
;
import
org.apache.atlas.model.typedef.AtlasTypeDefHeader
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.store.AtlasTypeDefStore
;
import
org.apache.atlas.store.AtlasTypeDefStore
;
...
@@ -45,9 +44,7 @@ import javax.ws.rs.PUT;
...
@@ -45,9 +44,7 @@ import javax.ws.rs.PUT;
import
javax.ws.rs.Path
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.WebApplicationException
;
import
javax.ws.rs.core.Context
;
import
javax.ws.rs.core.Context
;
import
javax.ws.rs.core.Response
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -56,106 +53,84 @@ import java.util.Set;
...
@@ -56,106 +53,84 @@ import java.util.Set;
@Singleton
@Singleton
public
class
TypesREST
{
public
class
TypesREST
{
private
AtlasTypeDefStore
typeDefStore
;
private
final
AtlasTypeDefStore
typeDefStore
;
@Context
private
HttpServletRequest
httpServletRequest
;
@Inject
@Inject
public
TypesREST
(
AtlasTypeDefStore
typeDefStore
)
{
public
TypesREST
(
AtlasTypeDefStore
typeDefStore
)
{
this
.
typeDefStore
=
typeDefStore
;
this
.
typeDefStore
=
typeDefStore
;
}
}
/******* EnumDef REST calls *******/
@POST
@GET
@Path
(
"/enumdef"
)
@Path
(
"/typedef/name/{name}"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Atlas
EnumDef
createEnumDef
(
AtlasEnumDef
enumDef
)
throws
AtlasBaseException
{
public
Atlas
BaseTypeDef
getTypeDefByName
(
@PathParam
(
"name"
)
String
name
)
throws
AtlasBaseException
{
Atlas
EnumDef
ret
=
typeDefStore
.
createEnumDef
(
enumDef
);
Atlas
BaseTypeDef
ret
=
typeDefStore
.
getByName
(
name
);
return
ret
;
return
ret
;
}
}
@GET
@GET
@Path
(
"/
enumdef/name/{name
}"
)
@Path
(
"/
typedef/guid/{guid
}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Atlas
EnumDef
getEnumDefByName
(
@PathParam
(
"name"
)
String
name
)
throws
AtlasBaseException
{
public
Atlas
BaseTypeDef
getTypeDefByGuid
(
@PathParam
(
"guid"
)
String
guid
)
throws
AtlasBaseException
{
Atlas
EnumDef
ret
=
typeDefStore
.
getEnumDefByName
(
name
);
Atlas
BaseTypeDef
ret
=
typeDefStore
.
getByGuid
(
guid
);
return
ret
;
return
ret
;
}
}
/**
* Bulk retrieval API for all type definitions returned as a list of minimal information header
* @return List of AtlasTypeDefHeader {@link AtlasTypeDefHeader}
* @throws AtlasBaseException
*/
@GET
@GET
@Path
(
"/
enumdef/guid/{guid}
"
)
@Path
(
"/
typedefs/headers
"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasEnumDef
getEnumDefByGuid
(
@PathParam
(
"guid"
)
String
guid
)
throws
AtlasBaseException
{
public
List
<
AtlasTypeDefHeader
>
getTypeDefHeaders
(
@Context
HttpServletRequest
httpServletRequest
)
throws
AtlasBaseException
{
AtlasEnumDef
ret
=
typeDefStore
.
getEnumDefByGuid
(
guid
);
SearchFilter
searchFilter
=
getSearchFilter
(
httpServletRequest
);
return
ret
;
AtlasTypesDef
searchTypesDef
=
typeDefStore
.
searchTypesDef
(
searchFilter
);
}
@PUT
@Path
(
"/enumdef/name/{name}"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasEnumDef
updateEnumDefByName
(
@PathParam
(
"name"
)
String
name
,
AtlasEnumDef
enumDef
)
throws
AtlasBaseException
{
AtlasEnumDef
ret
=
typeDefStore
.
updateEnumDefByName
(
name
,
enumDef
);
return
ret
;
return
AtlasTypeUtil
.
toTypeDefHeader
(
searchTypesDef
)
;
}
}
@PUT
/**
@Path
(
"/enumdef/guid/{guid}"
)
* Bulk retrieval API for retrieving all type definitions in Atlas
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
* @return A composite wrapper object with lists of all type definitions
* @throws Exception
*/
@GET
@Path
(
"/typedefs"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasEnumDef
updateEnumDefByGuid
(
@PathParam
(
"guid"
)
String
guid
,
AtlasEnumDef
enumDef
)
throws
AtlasBaseException
{
public
AtlasTypesDef
getAllTypeDefs
(
@Context
HttpServletRequest
httpServletRequest
)
throws
AtlasBaseException
{
AtlasEnumDef
ret
=
typeDefStore
.
updateEnumDefByGuid
(
guid
,
enumDef
);
SearchFilter
searchFilter
=
getSearchFilter
(
httpServletRequest
);
return
ret
;
}
@DELETE
AtlasTypesDef
typesDef
=
typeDefStore
.
searchTypesDef
(
searchFilter
);
@Path
(
"/enumdef/name/{name}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
void
deleteEnumDefByName
(
@PathParam
(
"name"
)
String
name
)
throws
AtlasBaseException
{
typeDefStore
.
deleteEnumDefByName
(
name
);
}
@DELETE
return
typesDef
;
@Path
(
"/enumdef/guid/{guid}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
void
deleteEnumDefByGuid
(
@PathParam
(
"guid"
)
String
guid
)
throws
AtlasBaseException
{
typeDefStore
.
deleteEnumDefByGuid
(
guid
);
}
}
@GET
@GET
@Path
(
"/enumdef"
)
@Path
(
"/enumdef
/name/{name}
"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasEnumDefs
searchEnumDefs
()
throws
AtlasBaseException
{
public
AtlasEnumDef
getEnumDefByName
(
@PathParam
(
"name"
)
String
name
)
throws
AtlasBaseException
{
AtlasEnumDefs
ret
=
null
;
AtlasEnumDef
ret
=
typeDefStore
.
getEnumDefByName
(
name
);
SearchFilter
filter
=
getSearchFilter
();
ret
=
typeDefStore
.
searchEnumDefs
(
filter
);
return
ret
;
return
ret
;
}
}
@GET
/******* StructDef REST calls *******/
@Path
(
"/enumdef/guid/{guid}"
)
@POST
@Path
(
"/structdef"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Atlas
StructDef
createStructDef
(
AtlasStructDef
structDef
)
throws
AtlasBaseException
{
public
Atlas
EnumDef
getEnumDefByGuid
(
@PathParam
(
"guid"
)
String
guid
)
throws
AtlasBaseException
{
Atlas
StructDef
ret
=
typeDefStore
.
createStructDef
(
structDef
);
Atlas
EnumDef
ret
=
typeDefStore
.
getEnumDefByGuid
(
guid
);
return
ret
;
return
ret
;
}
}
@GET
@GET
@Path
(
"/structdef/name/{name}"
)
@Path
(
"/structdef/name/{name}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
...
@@ -174,62 +149,6 @@ public class TypesREST {
...
@@ -174,62 +149,6 @@ public class TypesREST {
return
ret
;
return
ret
;
}
}
@PUT
@Path
(
"/structdef/name/{name}"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasStructDef
updateStructDefByName
(
@PathParam
(
"name"
)
String
name
,
AtlasStructDef
structDef
)
throws
AtlasBaseException
{
AtlasStructDef
ret
=
typeDefStore
.
updateStructDefByName
(
name
,
structDef
);
return
ret
;
}
@PUT
@Path
(
"/structdef/guid/{guid}"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasStructDef
updateStructDefByGuid
(
@PathParam
(
"guid"
)
String
guid
,
AtlasStructDef
structDef
)
throws
AtlasBaseException
{
AtlasStructDef
ret
=
typeDefStore
.
updateStructDefByGuid
(
guid
,
structDef
);
return
ret
;
}
@DELETE
@Path
(
"/structdef/name/{name}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
void
deleteStructDefByName
(
@PathParam
(
"name"
)
String
name
)
throws
AtlasBaseException
{
typeDefStore
.
deleteStructDefByName
(
name
);
}
@DELETE
@Path
(
"/structdef/guid/{guid}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
void
deleteStructDefByGuid
(
@PathParam
(
"guid"
)
String
guid
)
throws
AtlasBaseException
{
typeDefStore
.
deleteStructDefByGuid
(
guid
);
}
@GET
@Path
(
"/structdef"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasStructDefs
searchStructDefs
()
throws
AtlasBaseException
{
SearchFilter
filter
=
getSearchFilter
();
AtlasStructDefs
ret
=
typeDefStore
.
searchStructDefs
(
filter
);
return
ret
;
}
/******* ClassificationDef REST calls *******/
@POST
@Path
(
"/classificationdef"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasClassificationDef
createClassificationDef
(
AtlasClassificationDef
classificationDef
)
throws
AtlasBaseException
{
AtlasClassificationDef
ret
=
typeDefStore
.
createClassificationDef
(
classificationDef
);
return
ret
;
}
@GET
@GET
@Path
(
"/classificationdef/name/{name}"
)
@Path
(
"/classificationdef/name/{name}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
...
@@ -248,63 +167,6 @@ public class TypesREST {
...
@@ -248,63 +167,6 @@ public class TypesREST {
return
ret
;
return
ret
;
}
}
@PUT
@Path
(
"/classificationdef/name/{name}"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasClassificationDef
updateClassificationDefByName
(
@PathParam
(
"name"
)
String
name
,
AtlasClassificationDef
classificationDef
)
throws
AtlasBaseException
{
AtlasClassificationDef
ret
=
typeDefStore
.
updateClassificationDefByName
(
name
,
classificationDef
);
return
ret
;
}
@PUT
@Path
(
"/classificationdef/guid/{guid}"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasClassificationDef
updateClassificationDefByGuid
(
@PathParam
(
"guid"
)
String
guid
,
AtlasClassificationDef
classificationDef
)
throws
AtlasBaseException
{
AtlasClassificationDef
ret
=
typeDefStore
.
updateClassificationDefByGuid
(
guid
,
classificationDef
);
return
ret
;
}
@DELETE
@Path
(
"/classificationdef/name/{name}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
void
deleteClassificationDefByName
(
@PathParam
(
"name"
)
String
name
)
throws
AtlasBaseException
{
typeDefStore
.
deleteClassificationDefByName
(
name
);
}
@DELETE
@Path
(
"/classificationdef/guid/{guid}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
void
deleteClassificationDefByGuid
(
@PathParam
(
"guid"
)
String
guid
)
throws
AtlasBaseException
{
typeDefStore
.
deleteClassificationDefByGuid
(
guid
);
}
@GET
@Path
(
"/classificationdef"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasClassificationDefs
searchClassificationDefs
()
throws
AtlasBaseException
{
SearchFilter
filter
=
getSearchFilter
();
AtlasClassificationDefs
ret
=
typeDefStore
.
searchClassificationDefs
(
filter
);
return
ret
;
}
/******* EntityDef REST calls *******/
@POST
@Path
(
"/entitydef"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasEntityDef
createEntityDef
(
AtlasEntityDef
entityDef
)
throws
AtlasBaseException
{
AtlasEntityDef
ret
=
typeDefStore
.
createEntityDef
(
entityDef
);
return
ret
;
}
@GET
@GET
@Path
(
"/entitydef/name/{name}"
)
@Path
(
"/entitydef/name/{name}"
)
...
@@ -324,91 +186,11 @@ public class TypesREST {
...
@@ -324,91 +186,11 @@ public class TypesREST {
return
ret
;
return
ret
;
}
}
@PUT
@Path
(
"/entitydef/name/{name}"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Experimental
public
AtlasEntityDef
updateEntityDefByName
(
@PathParam
(
"name"
)
String
name
,
AtlasEntityDef
entityDef
)
throws
AtlasBaseException
{
AtlasEntityDef
ret
=
typeDefStore
.
updateEntityDefByName
(
name
,
entityDef
);
return
ret
;
}
@PUT
@Path
(
"/entitydef/guid/{guid}"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Experimental
public
AtlasEntityDef
updateEntityDefByGuid
(
@PathParam
(
"guid"
)
String
guid
,
AtlasEntityDef
entityDef
)
throws
AtlasBaseException
{
AtlasEntityDef
ret
=
typeDefStore
.
updateEntityDefByGuid
(
guid
,
entityDef
);
return
ret
;
}
@DELETE
@Path
(
"/entitydef/name/{name}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Experimental
public
void
deleteEntityDef
(
@PathParam
(
"name"
)
String
name
)
throws
AtlasBaseException
{
typeDefStore
.
deleteEntityDefByName
(
name
);
}
@DELETE
@Path
(
"/entitydef/guid/{guid}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Experimental
public
void
deleteEntityDefByGuid
(
@PathParam
(
"guid"
)
String
guid
)
throws
AtlasBaseException
{
typeDefStore
.
deleteEntityDefByGuid
(
guid
);
}
@GET
@Path
(
"/entitydef"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasEntityDefs
searchEntityDefs
()
throws
AtlasBaseException
{
SearchFilter
filter
=
getSearchFilter
();
AtlasEntityDefs
ret
=
typeDefStore
.
searchEntityDefs
(
filter
);
return
ret
;
}
/******************************************************************/
/******************************************************************/
/** Bulk API operations **/
/** Bulk API operations **/
/******************************************************************/
/******************************************************************/
/**
/**
* Bulk retrieval API for all type definitions returned as a list of minimal information header
* @return List of AtlasTypeDefHeader {@link AtlasTypeDefHeader}
* @throws AtlasBaseException
*/
@GET
@Path
(
"/typedefs/headers"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
List
<
AtlasTypeDefHeader
>
getTypeDefHeaders
()
throws
AtlasBaseException
{
SearchFilter
searchFilter
=
getSearchFilter
();
AtlasTypesDef
searchTypesDef
=
typeDefStore
.
searchTypesDef
(
searchFilter
);
return
AtlasTypeUtil
.
toTypeDefHeader
(
searchTypesDef
);
}
/**
* Bulk retrieval API for retrieving all type definitions in Atlas
* @return A composite wrapper object with lists of all type definitions
* @throws Exception
*/
@GET
@Path
(
"/typedefs"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasTypesDef
getAllTypeDefs
()
throws
AtlasBaseException
{
SearchFilter
searchFilter
=
getSearchFilter
();
AtlasTypesDef
typesDef
=
typeDefStore
.
searchTypesDef
(
searchFilter
);
return
typesDef
;
}
/**
* Bulk create APIs for all atlas type definitions, only new definitions will be created.
* Bulk create APIs for all atlas type definitions, only new definitions will be created.
* Any changes to the existing definitions will be discarded
* Any changes to the existing definitions will be discarded
* @param typesDef A composite wrapper object with corresponding lists of the type definition
* @param typesDef A composite wrapper object with corresponding lists of the type definition
...
@@ -461,7 +243,7 @@ public class TypesREST {
...
@@ -461,7 +243,7 @@ public class TypesREST {
* Populate a SearchFilter on the basis of the Query Parameters
* Populate a SearchFilter on the basis of the Query Parameters
* @return
* @return
*/
*/
private
SearchFilter
getSearchFilter
()
{
private
SearchFilter
getSearchFilter
(
HttpServletRequest
httpServletRequest
)
{
SearchFilter
ret
=
new
SearchFilter
();
SearchFilter
ret
=
new
SearchFilter
();
Set
<
String
>
keySet
=
httpServletRequest
.
getParameterMap
().
keySet
();
Set
<
String
>
keySet
=
httpServletRequest
.
getParameterMap
().
keySet
();
for
(
String
key
:
keySet
)
{
for
(
String
key
:
keySet
)
{
...
...
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