Repository: incubator-atlas Updated Branches: refs/heads/master 9cb56c541 -> 0fe4d8854
ATLAS-1534: TypesREST clean up for simpler REST interface Signed-off-by: Madhan Neethiraj <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/0fe4d885 Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/0fe4d885 Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/0fe4d885 Branch: refs/heads/master Commit: 0fe4d8854c3c263327b8f3b9120bd826cb2c1f11 Parents: 9cb56c5 Author: apoorvnaik <[email protected]> Authored: Tue Feb 7 13:24:25 2017 -0800 Committer: Madhan Neethiraj <[email protected]> Committed: Thu Feb 9 22:33:21 2017 -0800 ---------------------------------------------------------------------- .../org/apache/atlas/AtlasTypedefClientV2.java | 32 +- .../java/org/apache/atlas/AtlasErrorCode.java | 12 +- .../apache/atlas/store/AtlasTypeDefStore.java | 66 +--- .../store/graph/AtlasTypeDefGraphStore.java | 266 ++++------------- .../store/graph/AtlasTypeDefGraphStoreTest.java | 53 ++-- .../store/graph/v1/AtlasEntityStoreV1Test.java | 4 +- .../atlas/web/resources/TypesResource.java | 2 +- .../org/apache/atlas/web/rest/TypesREST.java | 298 +++---------------- 8 files changed, 167 insertions(+), 566 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/0fe4d885/client/src/main/java/org/apache/atlas/AtlasTypedefClientV2.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/atlas/AtlasTypedefClientV2.java b/client/src/main/java/org/apache/atlas/AtlasTypedefClientV2.java index 0ce811b..a48b6fb 100644 --- a/client/src/main/java/org/apache/atlas/AtlasTypedefClientV2.java +++ b/client/src/main/java/org/apache/atlas/AtlasTypedefClientV2.java @@ -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); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/0fe4d885/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java index aed5140..5902463 100644 --- a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java +++ b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java @@ -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; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/0fe4d885/intg/src/main/java/org/apache/atlas/store/AtlasTypeDefStore.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/store/AtlasTypeDefStore.java b/intg/src/main/java/org/apache/atlas/store/AtlasTypeDefStore.java index 95c5e64..9564b0c 100644 --- a/intg/src/main/java/org/apache/atlas/store/AtlasTypeDefStore.java +++ b/intg/src/main/java/org/apache/atlas/store/AtlasTypeDefStore.java @@ -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; } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/0fe4d885/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java index 7bd8a83..0f5b726 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java @@ -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={}, classifications={}, 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 { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/0fe4d885/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java index 3b72032..84ad72c 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java @@ -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 { - AtlasClassificationDef created = typeDefStore.createClassificationDef(classificationDef); + AtlasTypesDef created = typeDefStore.createTypesDef(typesDef); 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 { - AtlasEntityDef created = typeDefStore.createEntityDef(entityDef); + AtlasTypesDef created = typeDefStore.createTypesDef(typesDef); fail("Entity creation with invalid supertype should've failed"); } catch (AtlasBaseException e) {} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/0fe4d885/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java index ed1e494..7505329 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java @@ -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<>(); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/0fe4d885/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java index 1081c45..e731669 100755 --- a/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java +++ b/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java @@ -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()); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/0fe4d885/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java index 1f7adf3..3203b71 100644 --- a/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java +++ b/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java @@ -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 AtlasEnumDef createEnumDef(AtlasEnumDef enumDef) throws AtlasBaseException { - AtlasEnumDef ret = typeDefStore.createEnumDef(enumDef); + public AtlasBaseTypeDef getTypeDefByName(@PathParam("name") String name) throws AtlasBaseException { + AtlasBaseTypeDef ret = typeDefStore.getByName(name); return ret; } @GET - @Path("/enumdef/name/{name}") + @Path("/typedef/guid/{guid}") @Produces(Servlets.JSON_MEDIA_TYPE) - public AtlasEnumDef getEnumDefByName(@PathParam("name") String name) throws AtlasBaseException { - AtlasEnumDef ret = typeDefStore.getEnumDefByName(name); + public AtlasBaseTypeDef getTypeDefByGuid(@PathParam("guid") String guid) throws AtlasBaseException { + AtlasBaseTypeDef 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 AtlasStructDef createStructDef(AtlasStructDef structDef) throws AtlasBaseException { - AtlasStructDef ret = typeDefStore.createStructDef(structDef); + public AtlasEnumDef getEnumDefByGuid(@PathParam("guid") String guid) throws AtlasBaseException { + AtlasEnumDef 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) {
