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
Feb 07, 2017
by
apoorvnaik
Committed by
Madhan Neethiraj
Feb 09, 2017
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
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
167 additions
and
566 deletions
+167
-566
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
+58
-208
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 {
return
getTypeDefByGuid
(
guid
,
AtlasEntityDef
.
class
);
}
@Deprecated
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
{
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
{
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
)
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
);
}
...
...
intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
View file @
0fe4d885
...
...
@@ -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"
),
CANNOT_MAP_ATTRIBUTE
(
400
,
"ATLAS40031E"
,
"cannot map attribute: {0} of type: {1} from vertex"
),
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
TYPE_NAME_NOT_FOUND
(
404
,
"ATLAS4041E"
,
"Given typename {0} was invalid"
),
...
...
@@ -71,6 +74,7 @@ public enum AtlasErrorCode {
INSTANCE_LINEAGE_QUERY_FAILED
(
404
,
"ATLAS4047E"
,
"Instance lineage 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_BY_UNIQUE_ATTRIBUTE_NOT_FOUND
(
404
,
"ATLAS40410E"
,
"Instance {0} with unique attribute {1}={2} does not exist"
),
// All data conflict errors go here
...
...
@@ -82,13 +86,7 @@ public enum AtlasErrorCode {
INTERNAL_ERROR
(
500
,
"ATLAS5001E"
,
"Internal server error {0}"
),
INDEX_CREATION_FAILED
(
500
,
"ATLAS5002E"
,
"Index creation 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"
),
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}"
);
FAILED_TO_OBTAIN_TYPE_UPDATE_LOCK
(
500
,
"ATLAS5004E"
,
"Failed to get the lock; another type update might be in progress. Please try again"
);
private
String
errorCode
;
private
String
errorMessage
;
...
...
intg/src/main/java/org/apache/atlas/store/AtlasTypeDefStore.java
View file @
0fe4d885
...
...
@@ -19,14 +19,12 @@ package org.apache.atlas.store;
import
org.apache.atlas.exception.AtlasBaseException
;
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.AtlasClassificationDefs
;
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.AtlasEnumDefs
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasStructDefs
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
java.util.List
;
...
...
@@ -37,13 +35,7 @@ import java.util.List;
public
interface
AtlasTypeDefStore
{
void
init
()
throws
AtlasBaseException
;
/***********************/
/** EnumDef operation **/
/***********************/
AtlasEnumDef
createEnumDef
(
AtlasEnumDef
enumDef
)
throws
AtlasBaseException
;
List
<
AtlasEnumDef
>
getAllEnumDefs
()
throws
AtlasBaseException
;
/* EnumDef operations */
AtlasEnumDef
getEnumDefByName
(
String
name
)
throws
AtlasBaseException
;
...
...
@@ -53,18 +45,7 @@ public interface AtlasTypeDefStore {
AtlasEnumDef
updateEnumDefByGuid
(
String
guid
,
AtlasEnumDef
enumDef
)
throws
AtlasBaseException
;
void
deleteEnumDefByName
(
String
name
)
throws
AtlasBaseException
;
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
;
/* StructDef operations */
AtlasStructDef
getStructDefByName
(
String
name
)
throws
AtlasBaseException
;
...
...
@@ -74,19 +55,7 @@ public interface AtlasTypeDefStore {
AtlasStructDef
updateStructDefByGuid
(
String
guid
,
AtlasStructDef
structDef
)
throws
AtlasBaseException
;
void
deleteStructDefByName
(
String
name
)
throws
AtlasBaseException
;
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
;
/* ClassificationDef operations */
AtlasClassificationDef
getClassificationDefByName
(
String
name
)
throws
AtlasBaseException
;
...
...
@@ -98,19 +67,7 @@ public interface AtlasTypeDefStore {
AtlasClassificationDef
updateClassificationDefByGuid
(
String
guid
,
AtlasClassificationDef
classificationDef
)
throws
AtlasBaseException
;
void
deleteClassificationDefByName
(
String
name
)
throws
AtlasBaseException
;
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
;
/* EntityDef operations */
AtlasEntityDef
getEntityDefByName
(
String
name
)
throws
AtlasBaseException
;
...
...
@@ -120,13 +77,7 @@ public interface AtlasTypeDefStore {
AtlasEntityDef
updateEntityDefByGuid
(
String
guid
,
AtlasEntityDef
entityDef
)
throws
AtlasBaseException
;
void
deleteEntityDefByName
(
String
name
)
throws
AtlasBaseException
;
void
deleteEntityDefByGuid
(
String
guid
)
throws
AtlasBaseException
;
AtlasEntityDefs
searchEntityDefs
(
SearchFilter
filter
)
throws
AtlasBaseException
;
/***** Bulk Operations *****/
/* Bulk Operations */
AtlasTypesDef
createTypesDef
(
AtlasTypesDef
atlasTypesDef
)
throws
AtlasBaseException
;
...
...
@@ -135,4 +86,9 @@ public interface AtlasTypeDefStore {
void
deleteTypesDef
(
AtlasTypesDef
atlasTypesDef
)
throws
AtlasBaseException
;
AtlasTypesDef
searchTypesDef
(
SearchFilter
searchFilter
)
throws
AtlasBaseException
;
/* Generic operation */
AtlasBaseTypeDef
getByName
(
String
name
)
throws
AtlasBaseException
;
AtlasBaseTypeDef
getByGuid
(
String
guid
)
throws
AtlasBaseException
;
}
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;
import
org.apache.atlas.listener.ChangedTypeDefs
;
import
org.apache.atlas.listener.TypeDefChangeListener
;
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.AtlasClassificationDefs
;
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.AtlasEnumDefs
;
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.repository.store.bootstrap.AtlasTypeDefStoreInitializer
;
import
org.apache.atlas.repository.util.FilterUtil
;
import
org.apache.atlas.store.AtlasTypeDefStore
;
import
org.apache.atlas.type.AtlasClassificationType
;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.type.AtlasEnumType
;
import
org.apache.atlas.type.AtlasStructType
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeUtil
;
import
org.apache.atlas.util.AtlasRepositoryConfiguration
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.Predicate
;
...
...
@@ -54,7 +54,6 @@ import org.slf4j.LoggerFactory;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -110,28 +109,6 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
@Override
@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
{
AtlasEnumDef
ret
=
typeRegistry
.
getEnumDefByName
(
name
);
if
(
ret
==
null
)
{
...
...
@@ -172,54 +149,6 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
@Override
@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
{
AtlasStructDef
ret
=
typeRegistry
.
getStructDefByName
(
name
);
...
...
@@ -264,56 +193,6 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
@Override
@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
{
AtlasClassificationDef
ret
=
typeRegistry
.
getClassificationDefByName
(
name
);
...
...
@@ -339,7 +218,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
@Override
@GraphTransaction
public
AtlasClassificationDef
updateClassificationDefByName
(
String
name
,
AtlasClassificationDef
classificationDef
)
throws
AtlasBaseException
{
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
ttr
.
updateTypeByName
(
name
,
classificationDef
);
...
...
@@ -350,7 +229,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
@Override
@GraphTransaction
public
AtlasClassificationDef
updateClassificationDefByGuid
(
String
guid
,
AtlasClassificationDef
classificationDef
)
throws
AtlasBaseException
{
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
ttr
.
updateTypeByGuid
(
guid
,
classificationDef
);
...
...
@@ -360,54 +239,6 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
@Override
@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
{
AtlasEntityDef
ret
=
typeRegistry
.
getEntityDefByName
(
name
);
...
...
@@ -452,39 +283,13 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
@Override
@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
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> AtlasTypeDefGraphStore.createTypesDef(enums={}, structs={}, classfications={}, entities={})"
,
CollectionUtils
.
size
(
typesDef
.
getEnumDefs
()),
CollectionUtils
.
size
(
typesDef
.
getStructDefs
()),
CollectionUtils
.
size
(
typesDef
.
getClassificationDefs
()),
CollectionUtils
.
size
(
typesDef
.
getEntityDefs
()));
LOG
.
debug
(
"==> AtlasTypeDefGraphStore.createTypesDef(enums={}, structs={}, class
i
fications={}, entities={})"
,
CollectionUtils
.
size
(
typesDef
.
getEnumDefs
()),
CollectionUtils
.
size
(
typesDef
.
getStructDefs
()),
CollectionUtils
.
size
(
typesDef
.
getClassificationDefs
()),
CollectionUtils
.
size
(
typesDef
.
getEntityDefs
()));
}
AtlasTypesDef
ret
=
new
AtlasTypesDef
();
...
...
@@ -826,6 +631,26 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
}
@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
{
try
{
init
();
...
...
@@ -848,6 +673,31 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
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
{
AtlasTransientTypeRegistry
ttr
=
typeRegistry
.
lockTypeRegistryForUpdate
(
typeUpdateLockMaxWaitTimeSeconds
);
...
...
@@ -885,8 +735,8 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
private
void
notifyListeners
(
AtlasTransientTypeRegistry
ttr
)
{
if
(
CollectionUtils
.
isNotEmpty
(
typeDefChangeListeners
))
{
ChangedTypeDefs
changedTypeDefs
=
new
ChangedTypeDefs
(
ttr
.
getAddedTypes
(),
ttr
.
getUpdatedTypes
(),
ttr
.
getDeleteedTypes
());
ttr
.
getUpdatedTypes
(),
ttr
.
getDeleteedTypes
());
for
(
TypeDefChangeListener
changeListener
:
typeDefChangeListeners
)
{
try
{
...
...
repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
View file @
0fe4d885
...
...
@@ -38,6 +38,7 @@ import org.testng.annotations.DataProvider;
import
org.testng.annotations.Guice
;
import
org.testng.annotations.Test
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -64,36 +65,16 @@ public class AtlasTypeDefGraphStoreTest {
@Test
(
priority
=
1
)
public
void
testGet
()
{
try
{
List
<
AtlasEnumDef
>
allEnumDefs
=
typeDefStore
.
getAllEnumDefs
();
assertNotNull
(
allEnumDefs
);
assertEquals
(
allEnumDefs
.
size
(),
0
);
}
catch
(
AtlasBaseException
e
)
{
fail
(
"Get should've succeeded"
,
e
);
}
try
{
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
);
AtlasTypesDef
typesDef
=
typeDefStore
.
searchTypesDef
(
new
SearchFilter
());
assertNotNull
(
typesDef
.
getEnumDefs
());
assertEquals
(
typesDef
.
getStructDefs
().
size
(),
0
);
assertNotNull
(
typesDef
.
getStructDefs
());
assertEquals
(
typesDef
.
getClassificationDefs
().
size
(),
0
);
assertNotNull
(
typesDef
.
getClassificationDefs
());
assertEquals
(
typesDef
.
getEntityDefs
().
size
(),
0
);
assertNotNull
(
typesDef
.
getEntityDefs
());
}
catch
(
AtlasBaseException
e
)
{
fail
(
"
Get should've succeeded"
,
e
);
fail
(
"
Search of types shouldn't have failed"
);
}
}
...
...
@@ -385,17 +366,25 @@ public class AtlasTypeDefGraphStoreTest {
@Test
(
dependsOnMethods
=
"testGet"
)
public
void
testCreateWithInvalidSuperTypes
(){
AtlasTypesDef
typesDef
;
// Test Classification with supertype
AtlasClassificationDef
classificationDef
=
TestUtilsV2
.
getClassificationWithInvalidSuperType
();
typesDef
=
new
AtlasTypesDef
();
typesDef
.
getClassificationDefs
().
add
(
classificationDef
);
try
{
Atlas
ClassificationDef
created
=
typeDefStore
.
createClassificationDef
(
classification
Def
);
Atlas
TypesDef
created
=
typeDefStore
.
createTypesDef
(
types
Def
);
fail
(
"Classification creation with invalid supertype should've failed"
);
}
catch
(
AtlasBaseException
e
)
{}
}
catch
(
AtlasBaseException
e
)
{
typesDef
=
null
;
}
// Test Entity with supertype
AtlasEntityDef
entityDef
=
TestUtilsV2
.
getEntityWithInvalidSuperType
();
typesDef
=
new
AtlasTypesDef
();
typesDef
.
getEntityDefs
().
add
(
entityDef
);
try
{
Atlas
EntityDef
created
=
typeDefStore
.
createEntityDef
(
entity
Def
);
Atlas
TypesDef
created
=
typeDefStore
.
createTypesDef
(
types
Def
);
fail
(
"Entity creation with invalid supertype should've failed"
);
}
catch
(
AtlasBaseException
e
)
{}
...
...
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;
import
javax.inject.Inject
;
import
java.lang.reflect.Constructor
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -737,7 +738,8 @@ public class AtlasEntityStoreV1Test {
AtlasTypeUtil
.
createOptionalAttrDef
(
arrayAttrName
,
"array<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
Map
<
String
,
AtlasEntity
>
entityCloneMap
=
new
HashMap
<>();
...
...
webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java
View file @
0fe4d885
...
...
@@ -283,7 +283,7 @@ public class TypesResource {
TypesREST
typesRest
=
resourceContext
.
getResource
(
TypesREST
.
class
);
JSONObject
response
=
new
JSONObject
();
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
.
COUNT
,
result
.
size
());
...
...
webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
View file @
0fe4d885
...
...
@@ -20,14 +20,13 @@ package org.apache.atlas.web.rest;
import
com.google.inject.Inject
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.SearchFilter
;
import
org.apache.atlas.model.TypeCategory
;
import
org.apache.atlas.model.typedef.AtlasBaseTypeDef
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef.AtlasClassificationDefs
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.model.typedef.AtlasEntityDef.AtlasEntityDefs
;
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.AtlasStructDefs
;
import
org.apache.atlas.model.typedef.AtlasTypeDefHeader
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.store.AtlasTypeDefStore
;
...
...
@@ -45,9 +44,7 @@ import javax.ws.rs.PUT;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.WebApplicationException
;
import
javax.ws.rs.core.Context
;
import
javax.ws.rs.core.Response
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -56,106 +53,84 @@ import java.util.Set;
@Singleton
public
class
TypesREST
{
private
AtlasTypeDefStore
typeDefStore
;
private
final
AtlasTypeDefStore
typeDefStore
;
@Context
private
HttpServletRequest
httpServletRequest
;
@Inject
public
TypesREST
(
AtlasTypeDefStore
typeDefStore
)
{
this
.
typeDefStore
=
typeDefStore
;
}
/******* EnumDef REST calls *******/
@POST
@Path
(
"/enumdef"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@GET
@Path
(
"/typedef/name/{name}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Atlas
EnumDef
createEnumDef
(
AtlasEnumDef
enumDef
)
throws
AtlasBaseException
{
Atlas
EnumDef
ret
=
typeDefStore
.
createEnumDef
(
enumDef
);
public
Atlas
BaseTypeDef
getTypeDefByName
(
@PathParam
(
"name"
)
String
name
)
throws
AtlasBaseException
{
Atlas
BaseTypeDef
ret
=
typeDefStore
.
getByName
(
name
);
return
ret
;
}
@GET
@Path
(
"/
enumdef/name/{name
}"
)
@Path
(
"/
typedef/guid/{guid
}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Atlas
EnumDef
getEnumDefByName
(
@PathParam
(
"name"
)
String
name
)
throws
AtlasBaseException
{
Atlas
EnumDef
ret
=
typeDefStore
.
getEnumDefByName
(
name
);
public
Atlas
BaseTypeDef
getTypeDefByGuid
(
@PathParam
(
"guid"
)
String
guid
)
throws
AtlasBaseException
{
Atlas
BaseTypeDef
ret
=
typeDefStore
.
getByGuid
(
guid
);
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
@Path
(
"/
enumdef/guid/{guid}
"
)
@Path
(
"/
typedefs/headers
"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasEnumDef
getEnumDefByGuid
(
@PathParam
(
"guid"
)
String
guid
)
throws
AtlasBaseException
{
AtlasEnumDef
ret
=
typeDefStore
.
getEnumDefByGuid
(
guid
);
public
List
<
AtlasTypeDefHeader
>
getTypeDefHeaders
(
@Context
HttpServletRequest
httpServletRequest
)
throws
AtlasBaseException
{
SearchFilter
searchFilter
=
getSearchFilter
(
httpServletRequest
);
return
ret
;
}
@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
);
AtlasTypesDef
searchTypesDef
=
typeDefStore
.
searchTypesDef
(
searchFilter
);
return
ret
;
return
AtlasTypeUtil
.
toTypeDefHeader
(
searchTypesDef
)
;
}
@PUT
@Path
(
"/enumdef/guid/{guid}"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
/**
* 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
AtlasEnumDef
updateEnumDefByGuid
(
@PathParam
(
"guid"
)
String
guid
,
AtlasEnumDef
enumDef
)
throws
AtlasBaseException
{
AtlasEnumDef
ret
=
typeDefStore
.
updateEnumDefByGuid
(
guid
,
enumDef
);
return
ret
;
}
public
AtlasTypesDef
getAllTypeDefs
(
@Context
HttpServletRequest
httpServletRequest
)
throws
AtlasBaseException
{
SearchFilter
searchFilter
=
getSearchFilter
(
httpServletRequest
);
@DELETE
@Path
(
"/enumdef/name/{name}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
void
deleteEnumDefByName
(
@PathParam
(
"name"
)
String
name
)
throws
AtlasBaseException
{
typeDefStore
.
deleteEnumDefByName
(
name
);
}
AtlasTypesDef
typesDef
=
typeDefStore
.
searchTypesDef
(
searchFilter
);
@DELETE
@Path
(
"/enumdef/guid/{guid}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
void
deleteEnumDefByGuid
(
@PathParam
(
"guid"
)
String
guid
)
throws
AtlasBaseException
{
typeDefStore
.
deleteEnumDefByGuid
(
guid
);
return
typesDef
;
}
@GET
@Path
(
"/enumdef"
)
@Path
(
"/enumdef
/name/{name}
"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasEnumDefs
searchEnumDefs
()
throws
AtlasBaseException
{
AtlasEnumDefs
ret
=
null
;
SearchFilter
filter
=
getSearchFilter
();
ret
=
typeDefStore
.
searchEnumDefs
(
filter
);
public
AtlasEnumDef
getEnumDefByName
(
@PathParam
(
"name"
)
String
name
)
throws
AtlasBaseException
{
AtlasEnumDef
ret
=
typeDefStore
.
getEnumDefByName
(
name
);
return
ret
;
}
/******* StructDef REST calls *******/
@POST
@Path
(
"/structdef"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@GET
@Path
(
"/enumdef/guid/{guid}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
Atlas
StructDef
createStructDef
(
AtlasStructDef
structDef
)
throws
AtlasBaseException
{
Atlas
StructDef
ret
=
typeDefStore
.
createStructDef
(
structDef
);
public
Atlas
EnumDef
getEnumDefByGuid
(
@PathParam
(
"guid"
)
String
guid
)
throws
AtlasBaseException
{
Atlas
EnumDef
ret
=
typeDefStore
.
getEnumDefByGuid
(
guid
);
return
ret
;
}
@GET
@Path
(
"/structdef/name/{name}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
...
...
@@ -174,62 +149,6 @@ public class TypesREST {
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
@Path
(
"/classificationdef/name/{name}"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
...
...
@@ -248,63 +167,6 @@ public class TypesREST {
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
@Path
(
"/entitydef/name/{name}"
)
...
...
@@ -324,91 +186,11 @@ public class TypesREST {
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 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.
* Any changes to the existing definitions will be discarded
* @param typesDef A composite wrapper object with corresponding lists of the type definition
...
...
@@ -461,7 +243,7 @@ public class TypesREST {
* Populate a SearchFilter on the basis of the Query Parameters
* @return
*/
private
SearchFilter
getSearchFilter
()
{
private
SearchFilter
getSearchFilter
(
HttpServletRequest
httpServletRequest
)
{
SearchFilter
ret
=
new
SearchFilter
();
Set
<
String
>
keySet
=
httpServletRequest
.
getParameterMap
().
keySet
();
for
(
String
key
:
keySet
)
{
...
...
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