You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ni...@apache.org on 2020/09/29 09:22:23 UTC

[atlas] branch branch-2.0 updated (9c1145e -> d7efa6e)

This is an automated email from the ASF dual-hosted git repository.

nixon pushed a change to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git.


    from 9c1145e  ATLAS-3949 : Relationship search API, add parameter to get classification attributes in search results
     new f220bce  ATLAS-3952 :- Authorize Super And SubTypes and depend entityType for type-read access while creating Classificationdef
     new d7efa6e  ATLAS-3962 : Include business metadata def header in typdefs headers API

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/atlas/type/AtlasTypeRegistry.java   |  4 ----
 .../java/org/apache/atlas/type/AtlasTypeUtil.java  |  5 +++++
 .../graph/v2/AtlasClassificationDefStoreV2.java    | 25 +++++++++++++++++-----
 3 files changed, 25 insertions(+), 9 deletions(-)


[atlas] 02/02: ATLAS-3962 : Include business metadata def header in typdefs headers API

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nixon pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit d7efa6e38021c7bc45210680bedf29b8aaa59609
Author: nixonrodrigues <ni...@apache.org>
AuthorDate: Tue Sep 29 10:28:10 2020 +0530

    ATLAS-3962 : Include business metadata def header in typdefs headers API
    
    Change-Id: I52783f36c59509fefeb75f56f3391a7ea6a261ce
    (cherry picked from commit 7ae0bea9680d78605e1362dfbea288518f0e50ff)
---
 intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java b/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
index 9abcd34..889e26d 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
@@ -366,6 +366,11 @@ public class AtlasTypeUtil {
                 headerList.add(new AtlasTypeDefHeader(relationshipDef));
             }
         }
+        if (CollectionUtils.isNotEmpty(typesDef.getBusinessMetadataDefs())) {
+            for (AtlasBusinessMetadataDef businessMetadataDef : typesDef.getBusinessMetadataDefs()) {
+                headerList.add(new AtlasTypeDefHeader(businessMetadataDef));
+            }
+        }
 
         return headerList;
     }


[atlas] 01/02: ATLAS-3952 :- Authorize Super And SubTypes and depend entityType for type-read access while creating Classificationdef

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nixon pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit f220bceab3fb8033a77c94a5f043550f995ce984
Author: nixonrodrigues <ni...@apache.org>
AuthorDate: Thu Sep 24 00:02:54 2020 +0530

    ATLAS-3952 :- Authorize Super And SubTypes and depend entityType for type-read access while creating Classificationdef
    
    Change-Id: Ieb78c49615173db7eb1ce4911700799dfa1083bd
    (cherry picked from commit 86e9149b031d62536fce6bb6fa815536d57144bc)
---
 .../org/apache/atlas/type/AtlasTypeRegistry.java   |  4 ----
 .../graph/v2/AtlasClassificationDefStoreV2.java    | 25 +++++++++++++++++-----
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java b/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
index 4a79b6f..4c7f8c6 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
@@ -750,10 +750,6 @@ public class AtlasTypeRegistry {
             }
 
             if (typeDef != null) {
-                if (this.isRegisteredType(typeDef.getName())) {
-                    throw new AtlasBaseException(AtlasErrorCode.TYPE_ALREADY_EXISTS, typeDef.getName());
-                }
-
                 if (typeDef.getClass().equals(AtlasEnumDef.class)) {
                     AtlasEnumDef enumDef = (AtlasEnumDef) typeDef;
 
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasClassificationDefStoreV2.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasClassificationDefStoreV2.java
index 9ffede4..93e7012 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasClassificationDefStoreV2.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasClassificationDefStoreV2.java
@@ -23,20 +23,21 @@ 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.AtlasBaseTypeDef;
 import org.apache.atlas.model.typedef.AtlasClassificationDef;
+import org.apache.atlas.model.typedef.AtlasEntityDef;
 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.collections.CollectionUtils;
 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.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -70,6 +71,11 @@ class AtlasClassificationDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasClassif
             throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, classificationDef.getName(), TypeCategory.TRAIT.name());
         }
 
+        verifyTypeReadAccess(classificationDef.getSuperTypes());
+        verifyTypeReadAccess(classificationDef.getEntityTypes());
+
+        AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_CREATE, classificationDef), "create classification-def ", classificationDef.getName());
+
         AtlasVertex ret = typeDefStore.findTypeVertexByName(classificationDef.getName());
 
         if (ret != null) {
@@ -93,8 +99,6 @@ class AtlasClassificationDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasClassif
             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);
@@ -363,4 +367,15 @@ class AtlasClassificationDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasClassif
 
         return m.matches();
     }
+
+    private void verifyTypeReadAccess(Set<String> types) throws AtlasBaseException {
+        if (CollectionUtils.isNotEmpty(types)) {
+            for (String type : types) {
+                AtlasBaseTypeDef def = typeRegistry.getTypeDefByName(type);
+                if (def != null) {
+                    AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_READ, def), "read type-def of category", def.getCategory(), def.getName());
+                }
+            }
+        }
+    }
 }