ATLAS-2490: updates to make usage of v1/v2 in class names consistent Signed-off-by: Madhan Neethiraj <mad...@apache.org> (cherry picked from commit 3d5b4880f3e3a35e9c441010096ede729204af43)
Project: http://git-wip-us.apache.org/repos/asf/atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/4823c8ed Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/4823c8ed Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/4823c8ed Branch: refs/heads/branch-1.0 Commit: 4823c8ed4eca08c60587cd175c5184a5544ef4e5 Parents: ff132de Author: apoorvnaik <apoorvn...@apache.org> Authored: Sun May 13 23:11:41 2018 -0700 Committer: Madhan Neethiraj <mad...@apache.org> Committed: Thu May 24 21:47:22 2018 -0700 ---------------------------------------------------------------------- .../authorize/AtlasAuthorizationUtils.java | 8 +- .../ClassificationSearchProcessor.java | 6 +- .../atlas/discovery/EntityDiscoveryService.java | 6 +- .../atlas/discovery/EntityLineageService.java | 12 +- .../discovery/FullTextSearchProcessor.java | 6 +- .../apache/atlas/discovery/SearchContext.java | 4 +- .../apache/atlas/discovery/SearchProcessor.java | 6 +- .../apache/atlas/glossary/GlossaryService.java | 12 +- .../repository/audit/EntityAuditListener.java | 4 +- .../repository/audit/EntityAuditListenerV2.java | 10 +- .../converters/AtlasInstanceConverter.java | 6 +- .../converters/TypeConverterUtil.java | 4 +- .../repository/graph/FullTextMapperV2.java | 6 +- .../graph/GraphBackedSearchIndexer.java | 3 +- .../atlas/repository/graph/GraphHelper.java | 44 +- .../atlas/repository/impexp/ExportService.java | 2 +- .../atlas/repository/impexp/ZipSource.java | 2 +- .../apache/atlas/repository/ogm/DataAccess.java | 2 +- .../store/graph/AtlasEntityStore.java | 2 +- .../repository/store/graph/BulkImporter.java | 2 +- .../store/graph/EntityGraphDiscovery.java | 4 - .../graph/EntityGraphDiscoveryContext.java | 2 +- .../store/graph/v1/AtlasAbstractDefStoreV1.java | 111 -- .../graph/v1/AtlasClassificationDefStoreV1.java | 364 ---- .../graph/v1/AtlasEntityChangeNotifier.java | 478 ----- .../store/graph/v1/AtlasEntityDefStoreV1.java | 358 ---- .../graph/v1/AtlasEntityGraphDiscoveryV1.java | 377 ---- .../store/graph/v1/AtlasEntityStoreV1.java | 781 -------- .../store/graph/v1/AtlasEntityStream.java | 88 - .../graph/v1/AtlasEntityStreamForImport.java | 72 - .../store/graph/v1/AtlasEnumDefStoreV1.java | 325 ---- .../store/graph/v1/AtlasGraphUtilsV1.java | 514 ----- .../graph/v1/AtlasRelationshipDefStoreV1.java | 508 ----- .../graph/v1/AtlasRelationshipStoreV1.java | 836 --------- .../store/graph/v1/AtlasStructDefStoreV1.java | 611 ------ .../graph/v1/AtlasTypeDefGraphStoreV1.java | 539 ------ .../graph/v1/AttributeMutationContext.java | 150 -- .../store/graph/v1/BulkImporterImpl.java | 206 -- .../store/graph/v1/DeleteHandlerV1.java | 30 +- .../store/graph/v1/EntityGraphMapper.java | 1774 ----------------- .../store/graph/v1/EntityGraphRetriever.java | 1104 ----------- .../store/graph/v1/EntityImportStream.java | 34 - .../store/graph/v1/EntityMutationContext.java | 155 -- .../repository/store/graph/v1/EntityStream.java | 31 - .../store/graph/v1/IDBasedEntityResolver.java | 83 - .../store/graph/v1/InMemoryMapEntityStream.java | 55 - .../store/graph/v1/InstanceGraphMapper.java | 32 - .../store/graph/v1/SoftDeleteHandlerV1.java | 15 +- .../graph/v1/UniqAttrBasedEntityResolver.java | 75 - .../store/graph/v2/AtlasAbstractDefStoreV2.java | 112 ++ .../graph/v2/AtlasClassificationDefStoreV2.java | 364 ++++ .../graph/v2/AtlasEntityChangeNotifier.java | 478 +++++ .../store/graph/v2/AtlasEntityDefStoreV2.java | 358 ++++ .../graph/v2/AtlasEntityGraphDiscoveryV2.java | 377 ++++ .../store/graph/v2/AtlasEntityStoreV2.java | 780 ++++++++ .../store/graph/v2/AtlasEntityStream.java | 88 + .../graph/v2/AtlasEntityStreamForImport.java | 72 + .../store/graph/v2/AtlasEnumDefStoreV2.java | 325 ++++ .../store/graph/v2/AtlasGraphUtilsV2.java | 514 +++++ .../graph/v2/AtlasRelationshipDefStoreV2.java | 508 +++++ .../graph/v2/AtlasRelationshipStoreV2.java | 837 +++++++++ .../store/graph/v2/AtlasStructDefStoreV2.java | 611 ++++++ .../graph/v2/AtlasTypeDefGraphStoreV2.java | 539 ++++++ .../graph/v2/AttributeMutationContext.java | 150 ++ .../store/graph/v2/BulkImporterImpl.java | 206 ++ .../store/graph/v2/EntityGraphMapper.java | 1775 ++++++++++++++++++ .../store/graph/v2/EntityGraphRetriever.java | 1104 +++++++++++ .../store/graph/v2/EntityImportStream.java | 34 + .../store/graph/v2/EntityMutationContext.java | 155 ++ .../repository/store/graph/v2/EntityStream.java | 31 + .../store/graph/v2/IDBasedEntityResolver.java | 83 + .../store/graph/v2/InMemoryMapEntityStream.java | 55 + .../store/graph/v2/InstanceGraphMapper.java | 32 + .../graph/v2/UniqAttrBasedEntityResolver.java | 75 + .../util/AtlasRepositoryConfiguration.java | 2 +- .../apache/atlas/util/SearchPredicateUtil.java | 4 +- .../test/java/org/apache/atlas/TestModules.java | 18 +- .../atlas/glossary/GlossaryServiceTest.java | 2 +- .../org/apache/atlas/query/BasicTestSetup.java | 4 +- .../repository/impexp/ExportServiceTest.java | 19 +- .../repository/impexp/ImportServiceTest.java | 6 +- .../impexp/ZipFileResourceTestUtils.java | 6 +- .../store/graph/AtlasTypeDefGraphStoreTest.java | 6 +- .../graph/v1/AtlasComplexAttributesTest.java | 512 ----- .../graph/v1/AtlasEntityDefStoreV1Test.java | 80 - ...AtlasEntityStoreV1BulkImportPercentTest.java | 167 -- .../store/graph/v1/AtlasEntityStoreV1Test.java | 942 ---------- .../store/graph/v1/AtlasEntityTestBase.java | 247 --- .../v1/AtlasRelationshipDefStoreV1Test.java | 336 ---- .../AtlasRelationshipStoreHardDeleteV1Test.java | 112 -- .../AtlasRelationshipStoreSoftDeleteV1Test.java | 116 -- .../graph/v1/AtlasRelationshipStoreV1Test.java | 633 ------- .../InverseReferenceUpdateHardDeleteV1Test.java | 75 - .../InverseReferenceUpdateSoftDeleteV1Test.java | 78 - .../graph/v1/InverseReferenceUpdateV1Test.java | 380 ---- .../graph/v2/AtlasComplexAttributesTest.java | 512 +++++ .../graph/v2/AtlasEntityDefStoreV2Test.java | 80 + ...AtlasEntityStoreV2BulkImportPercentTest.java | 167 ++ .../store/graph/v2/AtlasEntityStoreV2Test.java | 942 ++++++++++ .../store/graph/v2/AtlasEntityTestBase.java | 248 +++ .../v2/AtlasRelationshipDefStoreV2Test.java | 336 ++++ .../AtlasRelationshipStoreHardDeleteV2Test.java | 113 ++ .../AtlasRelationshipStoreSoftDeleteV2Test.java | 117 ++ .../graph/v2/AtlasRelationshipStoreV2Test.java | 633 +++++++ .../InverseReferenceUpdateHardDeleteV2Test.java | 76 + .../InverseReferenceUpdateSoftDeleteV2Test.java | 79 + .../graph/v2/InverseReferenceUpdateV2Test.java | 380 ++++ .../ClassificationPropagationTest.java | 4 +- .../java/org/apache/atlas/RequestContext.java | 186 ++ .../java/org/apache/atlas/RequestContextV1.java | 186 -- .../EntityNotificationListenerV2.java | 16 +- .../notification/NotificationHookConsumer.java | 15 +- .../web/filters/AtlasAuthenticationFilter.java | 1 - .../apache/atlas/web/filters/AuditFilter.java | 8 +- .../atlas/web/resources/EntityResource.java | 6 +- .../org/apache/atlas/web/rest/EntityREST.java | 5 +- .../NotificationHookConsumerKafkaTest.java | 2 +- .../NotificationHookConsumerTest.java | 2 +- .../org/apache/atlas/util/RestUtilsTest.java | 22 +- .../atlas/web/adapters/TestEntitiesREST.java | 4 +- .../atlas/web/adapters/TestEntityREST.java | 4 +- .../AtlasAuthenticationKerberosFilterTest.java | 4 +- 122 files changed, 13707 insertions(+), 13708 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/authorization/src/main/java/org/apache/atlas/authorize/AtlasAuthorizationUtils.java ---------------------------------------------------------------------- diff --git a/authorization/src/main/java/org/apache/atlas/authorize/AtlasAuthorizationUtils.java b/authorization/src/main/java/org/apache/atlas/authorize/AtlasAuthorizationUtils.java index e7726b9..cc5db2f 100644 --- a/authorization/src/main/java/org/apache/atlas/authorize/AtlasAuthorizationUtils.java +++ b/authorization/src/main/java/org/apache/atlas/authorize/AtlasAuthorizationUtils.java @@ -20,6 +20,7 @@ package org.apache.atlas.authorize; import org.apache.atlas.AtlasErrorCode; +import org.apache.atlas.RequestContext; import org.apache.atlas.exception.AtlasBaseException; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; @@ -33,7 +34,6 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.util.HashSet; import java.util.Set; -import org.apache.atlas.RequestContextV1; public class AtlasAuthorizationUtils { private static final Logger LOG = LoggerFactory.getLogger(AtlasAuthorizationUtils.class); @@ -71,7 +71,7 @@ public class AtlasAuthorizationUtils { AtlasAuthorizer authorizer = AtlasAuthorizerFactory.getAtlasAuthorizer(); request.setUser(userName, getCurrentUserGroups()); - request.setClientIPAddress(RequestContextV1.get().getClientIPAddress()); + request.setClientIPAddress(RequestContext.get().getClientIPAddress()); ret = authorizer.isAccessAllowed(request); } catch (AtlasAuthorizationException e) { LOG.error("Unable to obtain AtlasAuthorizer", e); @@ -92,7 +92,7 @@ public class AtlasAuthorizationUtils { AtlasAuthorizer authorizer = AtlasAuthorizerFactory.getAtlasAuthorizer(); request.setUser(getCurrentUserName(), getCurrentUserGroups()); - request.setClientIPAddress(RequestContextV1.get().getClientIPAddress()); + request.setClientIPAddress(RequestContext.get().getClientIPAddress()); ret = authorizer.isAccessAllowed(request); } catch (AtlasAuthorizationException e) { LOG.error("Unable to obtain AtlasAuthorizer", e); @@ -113,7 +113,7 @@ public class AtlasAuthorizationUtils { AtlasAuthorizer authorizer = AtlasAuthorizerFactory.getAtlasAuthorizer(); request.setUser(getCurrentUserName(), getCurrentUserGroups()); - request.setClientIPAddress(RequestContextV1.get().getClientIPAddress()); + request.setClientIPAddress(RequestContext.get().getClientIPAddress()); ret = authorizer.isAccessAllowed(request); } catch (AtlasAuthorizationException e) { LOG.error("Unable to obtain AtlasAuthorizer", e); http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/discovery/ClassificationSearchProcessor.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/discovery/ClassificationSearchProcessor.java b/repository/src/main/java/org/apache/atlas/discovery/ClassificationSearchProcessor.java index 92acb5f..b5e75fe 100644 --- a/repository/src/main/java/org/apache/atlas/discovery/ClassificationSearchProcessor.java +++ b/repository/src/main/java/org/apache/atlas/discovery/ClassificationSearchProcessor.java @@ -27,7 +27,7 @@ import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraphQuery; import org.apache.atlas.repository.graphdb.AtlasIndexQuery; import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; +import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2; import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.util.AtlasGremlinQueryProvider; import org.apache.atlas.util.SearchPredicateUtil; @@ -268,11 +268,11 @@ public class ClassificationSearchProcessor extends SearchProcessor { for (AtlasEdge edge : edges) { AtlasVertex entityVertex = edge.getOutVertex(); - if (activeOnly && AtlasGraphUtilsV1.getState(entityVertex) != AtlasEntity.Status.ACTIVE) { + if (activeOnly && AtlasGraphUtilsV2.getState(entityVertex) != AtlasEntity.Status.ACTIVE) { continue; } - String guid = AtlasGraphUtilsV1.getIdFromVertex(entityVertex); + String guid = AtlasGraphUtilsV2.getIdFromVertex(entityVertex); if (processedGuids.contains(guid)) { continue; http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java b/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java index e443d9d..9d0cc9d 100644 --- a/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java +++ b/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java @@ -42,8 +42,8 @@ import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasIndexQuery; import org.apache.atlas.repository.graphdb.AtlasIndexQuery.Result; import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; -import org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever; +import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2; +import org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever; import org.apache.atlas.repository.userprofile.UserProfileService; import org.apache.atlas.type.AtlasArrayType; import org.apache.atlas.type.AtlasBuiltInTypes.AtlasObjectIdType; @@ -112,7 +112,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService { this.maxResultSetSize = ApplicationProperties.get().getInt(Constants.INDEX_SEARCH_MAX_RESULT_SET_SIZE, 150); this.maxTypesLengthInIdxQuery = ApplicationProperties.get().getInt(Constants.INDEX_SEARCH_TYPES_MAX_QUERY_STR_LENGTH, 512); this.maxTagsLengthInIdxQuery = ApplicationProperties.get().getInt(Constants.INDEX_SEARCH_TAGS_MAX_QUERY_STR_LENGTH, 512); - this.indexSearchPrefix = AtlasGraphUtilsV1.getIndexSearchPrefix(); + this.indexSearchPrefix = AtlasGraphUtilsV2.getIndexSearchPrefix(); this.userProfileService = userProfileService; } http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java b/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java index 633ad7c..8e5a448 100644 --- a/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java +++ b/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java @@ -37,8 +37,8 @@ import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.graphdb.AtlasEdge; import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; -import org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever; +import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2; +import org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever; import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeUtil; @@ -126,7 +126,7 @@ public class EntityLineageService implements AtlasLineageService { Map<String, Object> lookupAttributes = new HashMap<>(); lookupAttributes.put("qualifiedName", datasetName); - String guid = AtlasGraphUtilsV1.getGuidByUniqueAttributes(hive_table, lookupAttributes); + String guid = AtlasGraphUtilsV2.getGuidByUniqueAttributes(hive_table, lookupAttributes); return getSchemaForHiveTableByGuid(guid); } @@ -220,9 +220,9 @@ public class EntityLineageService implements AtlasLineageService { private void processEdge(final AtlasEdge edge, final Map<String, AtlasEntityHeader> entities, final Set<LineageRelation> relations) throws AtlasBaseException { AtlasVertex inVertex = edge.getInVertex(); AtlasVertex outVertex = edge.getOutVertex(); - String inGuid = AtlasGraphUtilsV1.getIdFromVertex(inVertex); - String outGuid = AtlasGraphUtilsV1.getIdFromVertex(outVertex); - String relationGuid = AtlasGraphUtilsV1.getProperty(edge, Constants.RELATIONSHIP_GUID_PROPERTY_KEY, String.class); + String inGuid = AtlasGraphUtilsV2.getIdFromVertex(inVertex); + String outGuid = AtlasGraphUtilsV2.getIdFromVertex(outVertex); + String relationGuid = AtlasGraphUtilsV2.getProperty(edge, Constants.RELATIONSHIP_GUID_PROPERTY_KEY, String.class); boolean isInputEdge = edge.getLabel().equalsIgnoreCase(PROCESS_INPUTS_EDGE); if (!entities.containsKey(inGuid)) { http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/discovery/FullTextSearchProcessor.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/discovery/FullTextSearchProcessor.java b/repository/src/main/java/org/apache/atlas/discovery/FullTextSearchProcessor.java index d205f71..dbbb435 100644 --- a/repository/src/main/java/org/apache/atlas/discovery/FullTextSearchProcessor.java +++ b/repository/src/main/java/org/apache/atlas/discovery/FullTextSearchProcessor.java @@ -22,7 +22,7 @@ import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.graphdb.AtlasIndexQuery; import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; +import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2; import org.apache.atlas.utils.AtlasPerfTracer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -124,7 +124,7 @@ public class FullTextSearchProcessor extends SearchProcessor { AtlasVertex vertex = idxQueryResult.next().getVertex(); // skip non-entity vertices - if (!AtlasGraphUtilsV1.isEntityVertex(vertex)) { + if (!AtlasGraphUtilsV2.isEntityVertex(vertex)) { if (LOG.isDebugEnabled()) { LOG.debug("FullTextSearchProcessor.execute(): ignoring non-entity vertex (id={})", vertex.getId()); } @@ -132,7 +132,7 @@ public class FullTextSearchProcessor extends SearchProcessor { continue; } - if (activeOnly && AtlasGraphUtilsV1.getState(vertex) != AtlasEntity.Status.ACTIVE) { + if (activeOnly && AtlasGraphUtilsV2.getState(vertex) != AtlasEntity.Status.ACTIVE) { continue; } http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/discovery/SearchContext.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/discovery/SearchContext.java b/repository/src/main/java/org/apache/atlas/discovery/SearchContext.java index 6e63061..1f40076 100644 --- a/repository/src/main/java/org/apache/atlas/discovery/SearchContext.java +++ b/repository/src/main/java/org/apache/atlas/discovery/SearchContext.java @@ -30,7 +30,7 @@ import org.apache.atlas.repository.graphdb.AtlasEdge; import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraphQuery; import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; +import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2; import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasStructType; @@ -238,7 +238,7 @@ public class SearchContext { AtlasEdge edge = edges.next(); AtlasVertex inVertex = edge.getInVertex(); - if (excludeDeletedEntities && AtlasGraphUtilsV1.getState(inVertex) == AtlasEntity.Status.DELETED) { + if (excludeDeletedEntities && AtlasGraphUtilsV2.getState(inVertex) == AtlasEntity.Status.DELETED) { continue; } ret.add(inVertex); http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java b/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java index 29fffa7..2e09bed 100644 --- a/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java +++ b/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java @@ -28,7 +28,7 @@ import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.graphdb.AtlasGraphQuery; import org.apache.atlas.repository.graphdb.AtlasIndexQuery; import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; +import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2; import org.apache.atlas.type.AtlasArrayType; import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEnumType; @@ -68,7 +68,7 @@ public abstract class SearchProcessor { public static final int MAX_RESULT_SIZE = getApplicationProperty(Constants.INDEX_SEARCH_MAX_RESULT_SET_SIZE, 150); public static final int MAX_QUERY_STR_LENGTH_TYPES = getApplicationProperty(Constants.INDEX_SEARCH_TYPES_MAX_QUERY_STR_LENGTH, 512); public static final int MAX_QUERY_STR_LENGTH_TAGS = getApplicationProperty(Constants.INDEX_SEARCH_TAGS_MAX_QUERY_STR_LENGTH, 512); - public static final String INDEX_SEARCH_PREFIX = AtlasGraphUtilsV1.getIndexSearchPrefix(); + public static final String INDEX_SEARCH_PREFIX = AtlasGraphUtilsV2.getIndexSearchPrefix(); public static final String AND_STR = " AND "; public static final String EMPTY_STRING = ""; public static final String SPACE_STRING = " "; @@ -784,7 +784,7 @@ public abstract class SearchProcessor { if (vertices != null) { for(AtlasVertex vertex : vertices) { - String guid = AtlasGraphUtilsV1.getIdFromVertex(vertex); + String guid = AtlasGraphUtilsV2.getIdFromVertex(vertex); if (StringUtils.isNotEmpty(guid)) { ret.add(guid); http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/glossary/GlossaryService.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/glossary/GlossaryService.java b/repository/src/main/java/org/apache/atlas/glossary/GlossaryService.java index 3467259..589ef7b 100644 --- a/repository/src/main/java/org/apache/atlas/glossary/GlossaryService.java +++ b/repository/src/main/java/org/apache/atlas/glossary/GlossaryService.java @@ -31,8 +31,8 @@ import org.apache.atlas.model.instance.AtlasRelatedObjectId; import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.ogm.DataAccess; import org.apache.atlas.repository.store.graph.AtlasRelationshipStore; -import org.apache.atlas.repository.store.graph.v1.AtlasEntityChangeNotifier; -import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; +import org.apache.atlas.repository.store.graph.v2.AtlasEntityChangeNotifier; +import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2; import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; @@ -94,7 +94,7 @@ public class GlossaryService { LOG.debug("==> GlossaryService.getGlossaries({}, {}, {})", limit, offset, sortOrder); } - List<String> glossaryGuids = AtlasGraphUtilsV1.findEntityGUIDsByType(GlossaryUtils.ATLAS_GLOSSARY_TYPENAME, sortOrder); + List<String> glossaryGuids = AtlasGraphUtilsV2.findEntityGUIDsByType(GlossaryUtils.ATLAS_GLOSSARY_TYPENAME, sortOrder); PaginationHelper paginationHelper = new PaginationHelper<>(glossaryGuids, offset, limit); List<AtlasGlossary> ret; @@ -916,21 +916,21 @@ public class GlossaryService { } private boolean glossaryExists(AtlasGlossary atlasGlossary) { - AtlasVertex vertex = AtlasGraphUtilsV1.findByUniqueAttributes(atlasTypeRegistry.getEntityTypeByName(GlossaryUtils.ATLAS_GLOSSARY_TYPENAME), new HashMap<String, Object>() {{ + AtlasVertex vertex = AtlasGraphUtilsV2.findByUniqueAttributes(atlasTypeRegistry.getEntityTypeByName(GlossaryUtils.ATLAS_GLOSSARY_TYPENAME), new HashMap<String, Object>() {{ put(QUALIFIED_NAME_ATTR, atlasGlossary.getQualifiedName()); }}); return Objects.nonNull(vertex); } private boolean termExists(AtlasGlossaryTerm term) { - AtlasVertex vertex = AtlasGraphUtilsV1.findByUniqueAttributes(atlasTypeRegistry.getEntityTypeByName(GlossaryUtils.ATLAS_GLOSSARY_TERM_TYPENAME), new HashMap<String, Object>() {{ + AtlasVertex vertex = AtlasGraphUtilsV2.findByUniqueAttributes(atlasTypeRegistry.getEntityTypeByName(GlossaryUtils.ATLAS_GLOSSARY_TERM_TYPENAME), new HashMap<String, Object>() {{ put(QUALIFIED_NAME_ATTR, term.getQualifiedName()); }}); return Objects.nonNull(vertex); } private boolean categoryExists(AtlasGlossaryCategory category) { - AtlasVertex vertex = AtlasGraphUtilsV1.findByUniqueAttributes(atlasTypeRegistry.getEntityTypeByName(GlossaryUtils.ATLAS_GLOSSARY_CATEGORY_TYPENAME), new HashMap<String, Object>() {{ + AtlasVertex vertex = AtlasGraphUtilsV2.findByUniqueAttributes(atlasTypeRegistry.getEntityTypeByName(GlossaryUtils.ATLAS_GLOSSARY_CATEGORY_TYPENAME), new HashMap<String, Object>() {{ put(QUALIFIED_NAME_ATTR, category.getQualifiedName()); }}); return Objects.nonNull(vertex); http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java b/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java index 7369c5e..27d121a 100644 --- a/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java +++ b/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java @@ -21,7 +21,7 @@ package org.apache.atlas.repository.audit; import org.apache.atlas.AtlasException; import org.apache.atlas.EntityAuditEvent; import org.apache.atlas.EntityAuditEvent.EntityAuditAction; -import org.apache.atlas.RequestContextV1; +import org.apache.atlas.RequestContext; import org.apache.atlas.listener.EntityChangeListener; import org.apache.atlas.model.glossary.AtlasGlossaryTerm; import org.apache.atlas.v1.model.instance.Referenceable; @@ -166,7 +166,7 @@ public class EntityAuditListener implements EntityChangeListener { private EntityAuditEvent createEvent(Referenceable entity, EntityAuditAction action, String details) throws AtlasException { - return new EntityAuditEvent(entity.getId()._getId(), RequestContextV1.get().getRequestTime(), RequestContextV1.get().getUser(), action, details, entity); + return new EntityAuditEvent(entity.getId()._getId(), RequestContext.get().getRequestTime(), RequestContext.get().getUser(), action, details, entity); } private String getAuditEventDetail(Referenceable entity, EntityAuditAction action) throws AtlasException { http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListenerV2.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListenerV2.java b/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListenerV2.java index a988e47..fe584e3 100644 --- a/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListenerV2.java +++ b/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListenerV2.java @@ -18,7 +18,7 @@ package org.apache.atlas.repository.audit; import org.apache.atlas.EntityAuditEvent.EntityAuditAction; -import org.apache.atlas.RequestContextV1; +import org.apache.atlas.RequestContext; import org.apache.atlas.model.audit.EntityAuditEventV2; import org.apache.atlas.model.audit.EntityAuditEventV2.EntityAuditActionV2; import org.apache.atlas.exception.AtlasBaseException; @@ -211,8 +211,8 @@ public class EntityAuditListenerV2 implements EntityChangeListenerV2 { } private EntityAuditEventV2 createEvent(AtlasEntity entity, EntityAuditActionV2 action, String details) { - return new EntityAuditEventV2(entity.getGuid(), RequestContextV1.get().getRequestTime(), - RequestContextV1.get().getUser(), action, details, entity); + return new EntityAuditEventV2(entity.getGuid(), RequestContext.get().getRequestTime(), + RequestContext.get().getUser(), action, details, entity); } private EntityAuditEventV2 createEvent(AtlasEntity entity, EntityAuditActionV2 action) { @@ -249,13 +249,13 @@ public class EntityAuditListenerV2 implements EntityChangeListenerV2 { } private boolean isPropagatedClassificationAdded(String guid, AtlasClassification classification) { - Map<String, List<AtlasClassification>> addedPropagations = RequestContextV1.get().getAddedPropagations(); + Map<String, List<AtlasClassification>> addedPropagations = RequestContext.get().getAddedPropagations(); return hasPropagatedEntry(addedPropagations, guid, classification); } private boolean isPropagatedClassificationDeleted(String guid, AtlasClassification classification) { - Map<String, List<AtlasClassification>> removedPropagations = RequestContextV1.get().getRemovedPropagations(); + Map<String, List<AtlasClassification>> removedPropagations = RequestContext.get().getRemovedPropagations(); return hasPropagatedEntry(removedPropagations, guid, classification); } http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java index 7d7e780..b26b353 100644 --- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java +++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java @@ -21,7 +21,7 @@ import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasException; import org.apache.atlas.CreateUpdateEntitiesResult; import org.apache.atlas.EntityAuditEvent; -import org.apache.atlas.RequestContextV1; +import org.apache.atlas.RequestContext; import org.apache.atlas.model.audit.EntityAuditEventV2; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.TypeCategory; @@ -33,7 +33,7 @@ import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.model.instance.EntityMutations.EntityOperation; import org.apache.atlas.model.instance.GuidMapping; import org.apache.atlas.model.legacy.EntityResult; -import org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever; +import org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever; import org.apache.atlas.v1.model.instance.Referenceable; import org.apache.atlas.v1.model.instance.Struct; import org.apache.atlas.repository.converters.AtlasFormatConverter.ConverterContext; @@ -293,7 +293,7 @@ public class AtlasInstanceConverter { public AtlasEntity.AtlasEntityWithExtInfo getAndCacheEntity(String guid) throws AtlasBaseException { - RequestContextV1 context = RequestContextV1.get(); + RequestContext context = RequestContext.get(); AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo = context.getInstanceV2(guid); if (entityWithExtInfo == null) { http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/repository/converters/TypeConverterUtil.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/TypeConverterUtil.java b/repository/src/main/java/org/apache/atlas/repository/converters/TypeConverterUtil.java index 1e06321..40d9a07 100644 --- a/repository/src/main/java/org/apache/atlas/repository/converters/TypeConverterUtil.java +++ b/repository/src/main/java/org/apache/atlas/repository/converters/TypeConverterUtil.java @@ -44,7 +44,7 @@ import org.apache.atlas.v1.model.typedef.Multiplicity; import org.apache.atlas.v1.model.typedef.StructTypeDefinition; import org.apache.atlas.v1.model.typedef.TraitTypeDefinition; import org.apache.atlas.v1.model.typedef.TypesDef; -import org.apache.atlas.repository.store.graph.v1.AtlasStructDefStoreV1; +import org.apache.atlas.repository.store.graph.v2.AtlasStructDefStoreV2; import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEnumType; @@ -360,7 +360,7 @@ public final class TypeConverterUtil { for (AtlasAttributeDef attrDef : attrDefs) { AtlasAttribute attribute = structType.getAttribute(attrDef.getName()); - AttributeDefinition oldAttrDef = AtlasStructDefStoreV1.toAttributeDefinition(attribute); + AttributeDefinition oldAttrDef = AtlasStructDefStoreV2.toAttributeDefinition(attribute); ret.add(new AttributeDefinition(oldAttrDef.getName(), oldAttrDef.getDataTypeName(), new Multiplicity(oldAttrDef.getMultiplicity()), oldAttrDef.getIsComposite(), oldAttrDef.getIsUnique(), oldAttrDef.getIsIndexable(), oldAttrDef.getReverseAttributeName())); } http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/repository/graph/FullTextMapperV2.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/FullTextMapperV2.java b/repository/src/main/java/org/apache/atlas/repository/graph/FullTextMapperV2.java index c42aa15..bc5ae5c 100644 --- a/repository/src/main/java/org/apache/atlas/repository/graph/FullTextMapperV2.java +++ b/repository/src/main/java/org/apache/atlas/repository/graph/FullTextMapperV2.java @@ -17,7 +17,7 @@ */ package org.apache.atlas.repository.graph; -import org.apache.atlas.RequestContextV1; +import org.apache.atlas.RequestContext; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.instance.AtlasClassification; import org.apache.atlas.model.instance.AtlasEntity; @@ -25,7 +25,7 @@ import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo; import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.AtlasStruct; -import org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever; +import org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever; import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; @@ -203,7 +203,7 @@ public class FullTextMapperV2 { } private AtlasEntityWithExtInfo getAndCacheEntity(String guid) throws AtlasBaseException { - RequestContextV1 context = RequestContextV1.get(); + RequestContext context = RequestContext.get(); AtlasEntityWithExtInfo entityWithExtInfo = context.getInstanceV2(guid); if (entityWithExtInfo == null) { http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java index f289365..4faa7ba 100755 --- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java +++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java @@ -42,7 +42,6 @@ import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraphIndex; import org.apache.atlas.repository.graphdb.AtlasGraphManagement; import org.apache.atlas.repository.graphdb.AtlasPropertyKey; -import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; import org.apache.atlas.type.AtlasArrayType; import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasEntityType; @@ -75,7 +74,7 @@ import static org.apache.atlas.repository.Constants.*; import static org.apache.atlas.repository.graphdb.AtlasCardinality.LIST; import static org.apache.atlas.repository.graphdb.AtlasCardinality.SET; import static org.apache.atlas.repository.graphdb.AtlasCardinality.SINGLE; -import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.isReference; +import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.isReference; import static org.apache.atlas.type.AtlasTypeUtil.isArrayType; import static org.apache.atlas.type.AtlasTypeUtil.isMapType; http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java index 57dc5bd..3ca2872 100755 --- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java +++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java @@ -24,13 +24,14 @@ import com.google.common.collect.HashBiMap; import org.apache.atlas.ApplicationProperties; import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasException; -import org.apache.atlas.RequestContextV1; +import org.apache.atlas.RequestContext; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.instance.AtlasEntity.Status; import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.AtlasRelationship; import org.apache.atlas.model.typedef.AtlasRelationshipDef; import org.apache.atlas.repository.graphdb.AtlasVertexQuery; +import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2; import org.apache.atlas.type.AtlasArrayType; import org.apache.atlas.type.AtlasMapType; import org.apache.atlas.util.AtlasGremlinQueryProvider; @@ -47,7 +48,6 @@ import org.apache.atlas.repository.graphdb.AtlasElement; import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraphQuery; import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasRelationshipType; import org.apache.atlas.type.AtlasType; @@ -86,7 +86,7 @@ import static org.apache.atlas.repository.Constants.CLASSIFICATION_EDGE_NAME_PRO import static org.apache.atlas.repository.Constants.CLASSIFICATION_VERTEX_NAME_KEY; import static org.apache.atlas.repository.Constants.CLASSIFICATION_VERTEX_PROPAGATE_KEY; import static org.apache.atlas.repository.Constants.PROPAGATED_TRAIT_NAMES_PROPERTY_KEY; -import static org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1.isReference; +import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.isReference; import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.BOTH; import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.IN; import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.OUT; @@ -185,12 +185,12 @@ public final class GraphHelper { setProperty(vertexWithoutIdentity, Constants.STATE_PROPERTY_KEY, Id.EntityState.ACTIVE.name()); // add timestamp information - setProperty(vertexWithoutIdentity, Constants.TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime()); + setProperty(vertexWithoutIdentity, Constants.TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime()); setProperty(vertexWithoutIdentity, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, - RequestContextV1.get().getRequestTime()); + RequestContext.get().getRequestTime()); - setProperty(vertexWithoutIdentity, Constants.CREATED_BY_KEY, RequestContextV1.get().getUser()); - setProperty(vertexWithoutIdentity, Constants.MODIFIED_BY_KEY, RequestContextV1.get().getUser()); + setProperty(vertexWithoutIdentity, Constants.CREATED_BY_KEY, RequestContext.get().getUser()); + setProperty(vertexWithoutIdentity, Constants.MODIFIED_BY_KEY, RequestContext.get().getUser()); return vertexWithoutIdentity; } @@ -198,8 +198,8 @@ public final class GraphHelper { AtlasEdge ret = addEdge(entityVertex, classificationVertex, CLASSIFICATION_LABEL); if (ret != null) { - AtlasGraphUtilsV1.setProperty(ret, CLASSIFICATION_EDGE_NAME_PROPERTY_KEY, getTypeName(classificationVertex)); - AtlasGraphUtilsV1.setProperty(ret, CLASSIFICATION_EDGE_IS_PROPAGATED_PROPERTY_KEY, isPropagated); + AtlasGraphUtilsV2.setProperty(ret, CLASSIFICATION_EDGE_NAME_PROPERTY_KEY, getTypeName(classificationVertex)); + AtlasGraphUtilsV2.setProperty(ret, CLASSIFICATION_EDGE_IS_PROPAGATED_PROPERTY_KEY, isPropagated); } return ret; @@ -216,10 +216,10 @@ public final class GraphHelper { if (ret != null) { setProperty(ret, Constants.STATE_PROPERTY_KEY, Id.EntityState.ACTIVE.name()); - setProperty(ret, Constants.TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime()); - setProperty(ret, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime()); - setProperty(ret, Constants.CREATED_BY_KEY, RequestContextV1.get().getUser()); - setProperty(ret, Constants.MODIFIED_BY_KEY, RequestContextV1.get().getUser()); + setProperty(ret, Constants.TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime()); + setProperty(ret, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime()); + setProperty(ret, Constants.CREATED_BY_KEY, RequestContext.get().getUser()); + setProperty(ret, Constants.MODIFIED_BY_KEY, RequestContext.get().getUser()); if (LOG.isDebugEnabled()) { LOG.debug("Added {}", string(ret)); @@ -376,7 +376,7 @@ public final class GraphHelper { boolean ret = false; if (classificationVertex != null) { - Boolean enabled = AtlasGraphUtilsV1.getProperty(classificationVertex, CLASSIFICATION_VERTEX_PROPAGATE_KEY, Boolean.class); + Boolean enabled = AtlasGraphUtilsV2.getProperty(classificationVertex, CLASSIFICATION_VERTEX_PROPAGATE_KEY, Boolean.class); ret = (enabled == null) ? true : enabled; } @@ -433,7 +433,7 @@ public final class GraphHelper { AtlasVertex classificationVertex = (edge != null) ? edge.getInVertex() : null; if (classificationVertex != null) { - String guid = AtlasGraphUtilsV1.getProperty(classificationVertex, CLASSIFICATION_ENTITY_GUID, String.class); + String guid = AtlasGraphUtilsV2.getProperty(classificationVertex, CLASSIFICATION_ENTITY_GUID, String.class); if (StringUtils.equals(guid, associatedEntityGuid)) { ret = edge; @@ -960,8 +960,8 @@ public final class GraphHelper { } public static void updateModificationMetadata(AtlasVertex vertex) { - AtlasGraphUtilsV1.setProperty(vertex, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime()); - AtlasGraphUtilsV1.setProperty(vertex, Constants.MODIFIED_BY_KEY, RequestContextV1.get().getUser()); + AtlasGraphUtilsV2.setProperty(vertex, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime()); + AtlasGraphUtilsV2.setProperty(vertex, Constants.MODIFIED_BY_KEY, RequestContext.get().getUser()); } public static String getQualifiedNameForMapKey(String prefix, String key) { @@ -1000,7 +1000,7 @@ public final class GraphHelper { while (iterator.hasNext()) { AtlasEdge edge = iterator.next(); - ret.add(AtlasGraphUtilsV1.getProperty(edge, CLASSIFICATION_EDGE_NAME_PROPERTY_KEY, String.class)); + ret.add(AtlasGraphUtilsV2.getProperty(edge, CLASSIFICATION_EDGE_NAME_PROPERTY_KEY, String.class)); } } @@ -1168,11 +1168,11 @@ public final class GraphHelper { } public static String getClassificationName(AtlasVertex classificationVertex) { - return AtlasGraphUtilsV1.getProperty(classificationVertex, CLASSIFICATION_VERTEX_NAME_KEY, String.class); + return AtlasGraphUtilsV2.getProperty(classificationVertex, CLASSIFICATION_VERTEX_NAME_KEY, String.class); } public static String getClassificationEntityGuid(AtlasVertex classificationVertex) { - return AtlasGraphUtilsV1.getProperty(classificationVertex, CLASSIFICATION_ENTITY_GUID, String.class); + return AtlasGraphUtilsV2.getProperty(classificationVertex, CLASSIFICATION_ENTITY_GUID, String.class); } public static Integer getIndexValue(AtlasEdge edge) { @@ -1198,7 +1198,7 @@ public final class GraphHelper { List<String> ret = null; if (edge != null) { - List<String> classificationIds = AtlasGraphUtilsV1.getProperty(edge, Constants.RELATIONSHIPTYPE_BLOCKED_PROPAGATED_CLASSIFICATIONS_KEY, List.class); + List<String> classificationIds = AtlasGraphUtilsV2.getProperty(edge, Constants.RELATIONSHIPTYPE_BLOCKED_PROPAGATED_CLASSIFICATIONS_KEY, List.class); ret = CollectionUtils.isNotEmpty(classificationIds) ? classificationIds : Collections.emptyList(); } @@ -1825,7 +1825,7 @@ public final class GraphHelper { Iterator<AtlasEdge> iter = entityVertex.getEdges(AtlasEdgeDirection.IN).iterator(); while (iter.hasNext() && ret == null) { - String edgeTypeName = AtlasGraphUtilsV1.getTypeName(iter.next()); + String edgeTypeName = AtlasGraphUtilsV2.getTypeName(iter.next()); for (AtlasRelationshipType relationType : relationshipTypes) { AtlasRelationshipDef relationshipDef = relationType.getRelationshipDef(); http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java b/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java index 6d6aa15..8bc3c20 100644 --- a/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java +++ b/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java @@ -37,7 +37,7 @@ import org.apache.atlas.model.typedef.AtlasStructDef; import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef; import org.apache.atlas.model.typedef.AtlasTypesDef; import org.apache.atlas.repository.graphdb.AtlasGraph; -import org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever; +import org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever; import org.apache.atlas.type.AtlasArrayType; import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasEntityType; http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/repository/impexp/ZipSource.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/impexp/ZipSource.java b/repository/src/main/java/org/apache/atlas/repository/impexp/ZipSource.java index ecfbd24..60cd9f8 100644 --- a/repository/src/main/java/org/apache/atlas/repository/impexp/ZipSource.java +++ b/repository/src/main/java/org/apache/atlas/repository/impexp/ZipSource.java @@ -22,7 +22,7 @@ import org.apache.atlas.model.impexp.AtlasExportResult; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo; import org.apache.atlas.model.typedef.AtlasTypesDef; -import org.apache.atlas.repository.store.graph.v1.EntityImportStream; +import org.apache.atlas.repository.store.graph.v2.EntityImportStream; import org.apache.atlas.type.AtlasType; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/repository/ogm/DataAccess.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/ogm/DataAccess.java b/repository/src/main/java/org/apache/atlas/repository/ogm/DataAccess.java index 470abce..6058867 100644 --- a/repository/src/main/java/org/apache/atlas/repository/ogm/DataAccess.java +++ b/repository/src/main/java/org/apache/atlas/repository/ogm/DataAccess.java @@ -24,7 +24,7 @@ import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo; import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.repository.store.graph.AtlasEntityStore; -import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream; +import org.apache.atlas.repository.store.graph.v2.AtlasEntityStream; import org.apache.atlas.utils.AtlasPerfTracer; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java index 82a82fb..be73a0d 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java @@ -23,7 +23,7 @@ import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo; import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.EntityMutationResponse; -import org.apache.atlas.repository.store.graph.v1.EntityStream; +import org.apache.atlas.repository.store.graph.v2.EntityStream; import org.apache.atlas.type.AtlasEntityType; import java.util.List; http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/repository/store/graph/BulkImporter.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/BulkImporter.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/BulkImporter.java index 7139eac..50d3b02 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/BulkImporter.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/BulkImporter.java @@ -20,7 +20,7 @@ package org.apache.atlas.repository.store.graph; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.impexp.AtlasImportResult; import org.apache.atlas.model.instance.EntityMutationResponse; -import org.apache.atlas.repository.store.graph.v1.EntityImportStream; +import org.apache.atlas.repository.store.graph.v2.EntityImportStream; public interface BulkImporter { http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/repository/store/graph/EntityGraphDiscovery.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/EntityGraphDiscovery.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/EntityGraphDiscovery.java index 23a25b9..6c859f6 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/EntityGraphDiscovery.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/EntityGraphDiscovery.java @@ -20,10 +20,6 @@ package org.apache.atlas.repository.store.graph; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.instance.AtlasEntity; -import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream; - -import java.util.List; -import java.util.Map; public interface EntityGraphDiscovery { http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/repository/store/graph/EntityGraphDiscoveryContext.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/EntityGraphDiscoveryContext.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/EntityGraphDiscoveryContext.java index ca62fdc..bd05c98 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/EntityGraphDiscoveryContext.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/EntityGraphDiscoveryContext.java @@ -20,7 +20,7 @@ package org.apache.atlas.repository.store.graph; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.repository.store.graph.v1.EntityStream; +import org.apache.atlas.repository.store.graph.v2.EntityStream; import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasTypeRegistry; import org.slf4j.Logger; http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasAbstractDefStoreV1.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasAbstractDefStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasAbstractDefStoreV1.java deleted file mode 100644 index 48973c3..0000000 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasAbstractDefStoreV1.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.atlas.repository.store.graph.v1; - -import org.apache.atlas.ApplicationProperties; -import org.apache.atlas.AtlasErrorCode; -import org.apache.atlas.AtlasException; -import org.apache.atlas.exception.AtlasBaseException; -import org.apache.atlas.model.typedef.AtlasBaseTypeDef; -import org.apache.atlas.model.typedef.AtlasStructDef; -import org.apache.atlas.query.AtlasDSL; -import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.repository.store.graph.AtlasDefStore; -import org.apache.atlas.type.AtlasTypeRegistry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.List; -import java.util.regex.Pattern; - -/** - * Abstract typedef-store for v1 format. - */ - abstract class AtlasAbstractDefStoreV1 <T extends AtlasBaseTypeDef> implements AtlasDefStore<T> { - private static final Logger LOG = LoggerFactory.getLogger(AtlasAbstractDefStoreV1.class); - protected final AtlasTypeDefGraphStoreV1 typeDefStore; - protected final AtlasTypeRegistry typeRegistry; - - private static final String NAME_REGEX = "[a-zA-Z][a-zA-Z0-9_ ]*"; - private static final String INTERNAL_NAME_REGEX = "__" + NAME_REGEX; - private static final Pattern NAME_PATTERN = Pattern.compile(NAME_REGEX); - private static final Pattern INTERNAL_NAME_PATTERN = Pattern.compile(INTERNAL_NAME_REGEX); - - public static final String ALLOW_RESERVED_KEYWORDS = "atlas.types.allowReservedKeywords"; - - public AtlasAbstractDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore, AtlasTypeRegistry typeRegistry) { - this.typeDefStore = typeDefStore; - this.typeRegistry = typeRegistry; - } - - public void validateType(AtlasBaseTypeDef typeDef) throws AtlasBaseException { - if (!isValidName(typeDef.getName())) { - throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID_FORMAT, typeDef.getName(), typeDef.getCategory().name()); - } - - try { - final boolean allowReservedKeywords = ApplicationProperties.get().getBoolean(ALLOW_RESERVED_KEYWORDS, true); - - if (!allowReservedKeywords && typeDef instanceof AtlasStructDef) { - final List<AtlasStructDef.AtlasAttributeDef> attributeDefs = ((AtlasStructDef) typeDef).getAttributeDefs(); - for (AtlasStructDef.AtlasAttributeDef attrDef : attributeDefs) { - if (AtlasDSL.Parser.isKeyword(attrDef.getName())) { - throw new AtlasBaseException(AtlasErrorCode.ATTRIBUTE_NAME_INVALID, attrDef.getName(), typeDef.getCategory().name()); - } - } - } - } catch (AtlasException e) { - LOG.error("Exception while loading configuration ", e); - throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, "Could not load configuration"); - } - } - - public boolean isValidName(String typeName) { - return NAME_PATTERN.matcher(typeName).matches() || INTERNAL_NAME_PATTERN.matcher(typeName).matches(); - } - - @Override - public void deleteByName(String name, AtlasVertex preDeleteResult) throws AtlasBaseException { - if (LOG.isDebugEnabled()) { - LOG.debug("==> AtlasAbstractDefStoreV1.deleteByName({}, {})", name, preDeleteResult); - } - - AtlasVertex vertex = (preDeleteResult == null) ? preDeleteByName(name) : preDeleteResult; - - typeDefStore.deleteTypeVertex(vertex); - - if (LOG.isDebugEnabled()) { - LOG.debug("<== AtlasAbstractDefStoreV1.deleteByName({}, {})", name, preDeleteResult); - } - } - - @Override - public void deleteByGuid(String guid, AtlasVertex preDeleteResult) throws AtlasBaseException { - if (LOG.isDebugEnabled()) { - LOG.debug("==> AtlasAbstractDefStoreV1.deleteByGuid({}, {})", guid, preDeleteResult); - } - - AtlasVertex vertex = (preDeleteResult == null) ? preDeleteByGuid(guid) : preDeleteResult; - - typeDefStore.deleteTypeVertex(vertex); - - if (LOG.isDebugEnabled()) { - LOG.debug("<== AtlasAbstractDefStoreV1.deleteByGuid({}, {})", guid, preDeleteResult); - } - } -} http://git-wip-us.apache.org/repos/asf/atlas/blob/4823c8ed/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java deleted file mode 100644 index be48372..0000000 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java +++ /dev/null @@ -1,364 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.atlas.repository.store.graph.v1; - - -import org.apache.atlas.AtlasErrorCode; -import org.apache.atlas.authorize.AtlasPrivilege; -import org.apache.atlas.authorize.AtlasAuthorizationUtils; -import org.apache.atlas.authorize.AtlasTypeAccessRequest; -import org.apache.atlas.exception.AtlasBaseException; -import org.apache.atlas.model.typedef.AtlasClassificationDef; -import org.apache.atlas.repository.Constants; -import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.type.AtlasClassificationType; -import org.apache.atlas.type.AtlasType; -import org.apache.atlas.type.AtlasTypeRegistry; -import org.apache.atlas.typesystem.types.DataTypes.TypeCategory; -import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * ClassificationDef store in v1 format. - */ -class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasClassificationDef> { - private static final Logger LOG = LoggerFactory.getLogger(AtlasClassificationDefStoreV1.class); - - private static final String TRAIT_NAME_REGEX = "[a-zA-Z][a-zA-Z0-9_ .]*"; - - private static final Pattern TRAIT_NAME_PATTERN = Pattern.compile(TRAIT_NAME_REGEX); - - public AtlasClassificationDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore, AtlasTypeRegistry typeRegistry) { - super(typeDefStore, typeRegistry); - } - - @Override - public AtlasVertex preCreate(AtlasClassificationDef classificationDef) throws AtlasBaseException { - if (LOG.isDebugEnabled()) { - LOG.debug("==> AtlasClassificationDefStoreV1.preCreate({})", classificationDef); - } - - validateType(classificationDef); - - AtlasType type = typeRegistry.getType(classificationDef.getName()); - - if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.CLASSIFICATION) { - throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, classificationDef.getName(), TypeCategory.TRAIT.name()); - } - - AtlasVertex ret = typeDefStore.findTypeVertexByName(classificationDef.getName()); - - if (ret != null) { - throw new AtlasBaseException(AtlasErrorCode.TYPE_ALREADY_EXISTS, classificationDef.getName()); - } - - ret = typeDefStore.createTypeVertex(classificationDef); - - updateVertexPreCreate(classificationDef, (AtlasClassificationType)type, ret); - - if (LOG.isDebugEnabled()) { - LOG.debug("<== AtlasClassificationDefStoreV1.preCreate({}): {}", classificationDef, ret); - } - - return ret; - } - - @Override - public AtlasClassificationDef create(AtlasClassificationDef classificationDef, AtlasVertex preCreateResult) throws AtlasBaseException { - if (LOG.isDebugEnabled()) { - LOG.debug("==> AtlasClassificationDefStoreV1.create({}, {})", classificationDef, preCreateResult); - } - - AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_CREATE, classificationDef), "create classification-def ", classificationDef.getName()); - - AtlasVertex vertex = (preCreateResult == null) ? preCreate(classificationDef) : preCreateResult; - - updateVertexAddReferences(classificationDef, vertex); - - AtlasClassificationDef ret = toClassificationDef(vertex); - - if (LOG.isDebugEnabled()) { - LOG.debug("<== AtlasClassificationDefStoreV1.create({}, {}): {}", classificationDef, preCreateResult, ret); - } - - return ret; - } - - @Override - public List<AtlasClassificationDef> getAll() throws AtlasBaseException { - if (LOG.isDebugEnabled()) { - LOG.debug("==> AtlasClassificationDefStoreV1.getAll()"); - } - - List<AtlasClassificationDef> ret = new ArrayList<>(); - - Iterator<AtlasVertex> vertices = typeDefStore.findTypeVerticesByCategory(TypeCategory.TRAIT); - while (vertices.hasNext()) { - ret.add(toClassificationDef(vertices.next())); - } - - if (LOG.isDebugEnabled()) { - LOG.debug("<== AtlasClassificationDefStoreV1.getAll(): count={}", ret.size()); - } - return ret; - } - - @Override - public AtlasClassificationDef getByName(String name) throws AtlasBaseException { - if (LOG.isDebugEnabled()) { - LOG.debug("==> AtlasClassificationDefStoreV1.getByName({})", name); - } - - AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.TRAIT); - - if (vertex == null) { - throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name); - } - - vertex.getProperty(Constants.TYPE_CATEGORY_PROPERTY_KEY, TypeCategory.class); - - AtlasClassificationDef ret = toClassificationDef(vertex); - - if (LOG.isDebugEnabled()) { - LOG.debug("<== AtlasClassificationDefStoreV1.getByName({}): {}", name, ret); - } - - return ret; - } - - @Override - public AtlasClassificationDef getByGuid(String guid) throws AtlasBaseException { - if (LOG.isDebugEnabled()) { - LOG.debug("==> AtlasClassificationDefStoreV1.getByGuid({})", guid); - } - - AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT); - - if (vertex == null) { - throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid); - } - - AtlasClassificationDef ret = toClassificationDef(vertex); - - if (LOG.isDebugEnabled()) { - LOG.debug("<== AtlasClassificationDefStoreV1.getByGuid({}): {}", guid, ret); - } - - return ret; - } - - @Override - public AtlasClassificationDef update(AtlasClassificationDef classifiDef) throws AtlasBaseException { - if (LOG.isDebugEnabled()) { - LOG.debug("==> AtlasClassificationDefStoreV1.update({})", classifiDef); - } - - validateType(classifiDef); - - AtlasClassificationDef ret = StringUtils.isNotBlank(classifiDef.getGuid()) - ? updateByGuid(classifiDef.getGuid(), classifiDef) : updateByName(classifiDef.getName(), classifiDef); - - if (LOG.isDebugEnabled()) { - LOG.debug("<== AtlasClassificationDefStoreV1.update({}): {}", classifiDef, ret); - } - - return ret; - } - - @Override - public AtlasClassificationDef updateByName(String name, AtlasClassificationDef classificationDef) - throws AtlasBaseException { - if (LOG.isDebugEnabled()) { - LOG.debug("==> AtlasClassificationDefStoreV1.updateByName({}, {})", name, classificationDef); - } - - AtlasClassificationDef existingDef = typeRegistry.getClassificationDefByName(name); - - AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_UPDATE, existingDef), "update classification-def ", name); - - validateType(classificationDef); - - AtlasType type = typeRegistry.getType(classificationDef.getName()); - - if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.CLASSIFICATION) { - throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, classificationDef.getName(), TypeCategory.TRAIT.name()); - } - - AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.TRAIT); - - if (vertex == null) { - throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name); - } - - updateVertexPreUpdate(classificationDef, (AtlasClassificationType)type, vertex); - updateVertexAddReferences(classificationDef, vertex); - - AtlasClassificationDef ret = toClassificationDef(vertex); - - if (LOG.isDebugEnabled()) { - LOG.debug("<== AtlasClassificationDefStoreV1.updateByName({}, {}): {}", name, classificationDef, ret); - } - - return ret; - } - - @Override - public AtlasClassificationDef updateByGuid(String guid, AtlasClassificationDef classificationDef) throws AtlasBaseException { - if (LOG.isDebugEnabled()) { - LOG.debug("==> AtlasClassificationDefStoreV1.updateByGuid({})", guid); - } - - AtlasClassificationDef existingDef = typeRegistry.getClassificationDefByGuid(guid); - - AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_UPDATE, existingDef), "update classification-def ", (existingDef != null ? existingDef.getName() : guid)); - - validateType(classificationDef); - - AtlasType type = typeRegistry.getTypeByGuid(guid); - - if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.CLASSIFICATION) { - throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, classificationDef.getName(), TypeCategory.TRAIT.name()); - } - - AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT); - - if (vertex == null) { - throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid); - } - - updateVertexPreUpdate(classificationDef, (AtlasClassificationType)type, vertex); - updateVertexAddReferences(classificationDef, vertex); - - AtlasClassificationDef ret = toClassificationDef(vertex); - - if (LOG.isDebugEnabled()) { - LOG.debug("<== AtlasClassificationDefStoreV1.updateByGuid({}): {}", guid, ret); - } - - return ret; - } - - @Override - public AtlasVertex preDeleteByName(String name) throws AtlasBaseException { - if (LOG.isDebugEnabled()) { - LOG.debug("==> AtlasClassificationDefStoreV1.preDeleteByName({})", name); - } - - AtlasClassificationDef existingDef = typeRegistry.getClassificationDefByName(name); - - AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_DELETE, existingDef), "delete classification-def ", name); - - AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.TRAIT); - - if (AtlasGraphUtilsV1.typeHasInstanceVertex(name)) { - throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name); - } - - if (ret == null) { - throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name); - } - - typeDefStore.deleteTypeVertexOutEdges(ret); - - if (LOG.isDebugEnabled()) { - LOG.debug("<== AtlasClassificationDefStoreV1.preDeleteByName({}): ret=", name, ret); - } - - return ret; - } - - @Override - public AtlasVertex preDeleteByGuid(String guid) throws AtlasBaseException { - if (LOG.isDebugEnabled()) { - LOG.debug("==> AtlasClassificationDefStoreV1.preDeleteByGuid({})", guid); - } - - AtlasClassificationDef existingDef = typeRegistry.getClassificationDefByGuid(guid); - - AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_DELETE, existingDef), "delete classification-def ", (existingDef != null ? existingDef.getName() : guid)); - - AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT); - - String typeName = AtlasGraphUtilsV1.getProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class); - - if (AtlasGraphUtilsV1.typeHasInstanceVertex(typeName)) { - throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, typeName); - } - - if (ret == null) { - throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid); - } - - typeDefStore.deleteTypeVertexOutEdges(ret); - - if (LOG.isDebugEnabled()) { - LOG.debug("<== AtlasClassificationDefStoreV1.preDeleteByGuid({}): ret=", guid, ret); - } - - return ret; - } - - private void updateVertexPreCreate(AtlasClassificationDef classificationDef, - AtlasClassificationType classificationType, - AtlasVertex vertex) throws AtlasBaseException { - AtlasStructDefStoreV1.updateVertexPreCreate(classificationDef, classificationType, vertex, typeDefStore); - } - - private void updateVertexPreUpdate(AtlasClassificationDef classificationDef, - AtlasClassificationType classificationType, - AtlasVertex vertex) throws AtlasBaseException { - AtlasStructDefStoreV1.updateVertexPreUpdate(classificationDef, classificationType, vertex, typeDefStore); - } - - private void updateVertexAddReferences(AtlasClassificationDef classificationDef, AtlasVertex vertex) throws AtlasBaseException { - AtlasStructDefStoreV1.updateVertexAddReferences(classificationDef, vertex, typeDefStore); - - typeDefStore.createSuperTypeEdges(vertex, classificationDef.getSuperTypes(), TypeCategory.TRAIT); - // create edges from this vertex to entity Type vertices with the supplied entity type names - typeDefStore.createEntityTypeEdges(vertex, classificationDef.getEntityTypes()); - } - - private AtlasClassificationDef toClassificationDef(AtlasVertex vertex) throws AtlasBaseException { - AtlasClassificationDef ret = null; - - if (vertex != null && typeDefStore.isTypeVertex(vertex, TypeCategory.TRAIT)) { - ret = new AtlasClassificationDef(); - - AtlasStructDefStoreV1.toStructDef(vertex, ret, typeDefStore); - - ret.setSuperTypes(typeDefStore.getSuperTypeNames(vertex)); - ret.setEntityTypes(typeDefStore.getEntityTypeNames(vertex)); - } - - return ret; - } - - @Override - public boolean isValidName(String typeName) { - Matcher m = TRAIT_NAME_PATTERN.matcher(typeName); - - return m.matches(); - } -}