You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2020/02/15 19:18:04 UTC
[atlas] branch branch-2.0 updated: ATLAS-3619: updated
namespace-def to allow attributes with no associated entity-types,
mandatory attributes and unique attributes
This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new b99c84a ATLAS-3619: updated namespace-def to allow attributes with no associated entity-types, mandatory attributes and unique attributes
b99c84a is described below
commit b99c84a89d8f15cad5db946eb04869573f5a0bb6
Author: Mandar Ambawane <ma...@freestoneinfotech.com>
AuthorDate: Sat Feb 15 20:38:46 2020 +0530
ATLAS-3619: updated namespace-def to allow attributes with no associated entity-types, mandatory attributes and unique attributes
Signed-off-by: Madhan Neethiraj <ma...@apache.org>
(cherry picked from commit 5e7f8949fd220533510c7ef92e38ac204612a509)
---
.../main/java/org/apache/atlas/AtlasErrorCode.java | 10 ++++------
.../org/apache/atlas/type/AtlasNamespaceType.java | 10 ----------
.../store/graph/v2/AtlasNamespaceDefStoreV2Test.java | 20 +-------------------
3 files changed, 5 insertions(+), 35 deletions(-)
diff --git a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
index 1670bda..04eb4a0 100644
--- a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
+++ b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
@@ -163,12 +163,10 @@ public enum AtlasErrorCode {
INVALID_PROPAGATION_TYPE(400, "ATLAS-400-00-091", "Invalid propagation {0} for relationship-type={1}. Default value is {2}"),
DUPLICATE_NAMESPACE_ATTRIBUTE(400, "ATLAS-400-00-092", "Duplicate Namespace Attributes: {0} not allowed within the same namespace: {1}"),
APPLICABLE_ENTITY_TYPES_DELETION_NOT_SUPPORTED(400, "ATLAS-400-00-093", "Cannot remove applicableEntityTypes in Attribute Def: {0}, defined in namespace: {1}"),
- NAMESPACE_DEF_MANDATORY_ATTRIBUTE_NOT_ALLOWED(400, "ATLAS-400-00-094", "{0}.{1} : namespaces can not have mandatory attribute"),
- NAMESPACE_DEF_UNIQUE_ATTRIBUTE_NOT_ALLOWED(400, "ATLAS-400-00-095", "{0}.{1} : namespaces can not have unique attribute"),
- NAMESPACE_DEF_ATTRIBUTE_TYPE_INVALID(400, "ATLAS-400-00-096", "{0}.{1}: invalid attribute type. Namespace attribute cannot be of type entity/classification/struct/namespace"),
- INVALID_NAMESPACE_NAME_FOR_ENTITY_TYPE(400, "ATLAS-400-00-097", "Invalid Namespace: {0} specified for entity, applicable namespaces: {1}"),
- NAMESPACE_ATTRIBUTE_DOES_NOT_EXIST(400, "ATLAS-400-00-098", "Namespace attribute does not exist in entity: {0}"),
- NAMESPACE_ATTRIBUTE_ALREADY_EXISTS(400, "ATLAS-400-00-099", "Namespace attribute already exists in entity: {0}"),
+ NAMESPACE_DEF_ATTRIBUTE_TYPE_INVALID(400, "ATLAS-400-00-094", "{0}.{1}: invalid attribute type. Namespace attribute cannot be of type entity/classification/struct/namespace"),
+ INVALID_NAMESPACE_NAME_FOR_ENTITY_TYPE(400, "ATLAS-400-00-095", "Invalid Namespace: {0} specified for entity, applicable namespaces: {1}"),
+ NAMESPACE_ATTRIBUTE_DOES_NOT_EXIST(400, "ATLAS-400-00-096", "Namespace attribute does not exist in entity: {0}"),
+ NAMESPACE_ATTRIBUTE_ALREADY_EXISTS(400, "ATLAS-400-00-097", "Namespace attribute already exists in entity: {0}"),
UNAUTHORIZED_ACCESS(403, "ATLAS-403-00-001", "{0} is not authorized to perform {1}"),
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasNamespaceType.java b/intg/src/main/java/org/apache/atlas/type/AtlasNamespaceType.java
index cfbf2b1..ede8443 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasNamespaceType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasNamespaceType.java
@@ -84,14 +84,6 @@ public class AtlasNamespaceType extends AtlasStructType {
throw new AtlasBaseException(AtlasErrorCode.NAMESPACE_DEF_ATTRIBUTE_TYPE_INVALID, getTypeName(), attrName);
}
- if (!attributeDef.getIsOptional()) {
- throw new AtlasBaseException(AtlasErrorCode.NAMESPACE_DEF_MANDATORY_ATTRIBUTE_NOT_ALLOWED, getTypeName(), attrName);
- }
-
- if (attributeDef.getIsUnique()) {
- throw new AtlasBaseException(AtlasErrorCode.NAMESPACE_DEF_UNIQUE_ATTRIBUTE_NOT_ALLOWED, getTypeName(), attrName);
- }
-
Set<String> entityTypeNames = attribute.getOptionSet(ATTR_OPTION_APPLICABLE_ENTITY_TYPES);
Set<AtlasEntityType> entityTypes = new HashSet<>();
@@ -105,8 +97,6 @@ public class AtlasNamespaceType extends AtlasStructType {
entityTypes.add(entityType);
}
- } else {
- throw new AtlasBaseException(AtlasErrorCode.MISSING_MANDATORY_ATTRIBUTE, attributeDef.getName(), "options." + ATTR_OPTION_APPLICABLE_ENTITY_TYPES);
}
AtlasNamespaceAttribute nsAttribute;
diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasNamespaceDefStoreV2Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasNamespaceDefStoreV2Test.java
index 1d6534e..8f6afc7 100644
--- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasNamespaceDefStoreV2Test.java
+++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasNamespaceDefStoreV2Test.java
@@ -166,25 +166,7 @@ public class AtlasNamespaceDefStoreV2Test {
typesDefs.setNamespaceDefs(Arrays.asList(namespaceDef));
typeDefStore.updateTypesDef(typesDefs);
} catch (AtlasBaseException e) {
- Assert.assertEquals(e.getAtlasErrorCode(), AtlasErrorCode.MISSING_MANDATORY_ATTRIBUTE);
- } finally {
- typesDefs = existingTypeDefs;
- }
- }
-
- /**
- * Test to verify that we cannot have an empty applicable entity types in an attribute definition
- * @throws AtlasBaseException
- */
- @Test
- public void createNsAttrDefWithoutApplicableEntityTypes() {
- AtlasTypesDef existingTypeDefs = typesDefs;
-
- try {
- typesDefs.setNamespaceDefs(Arrays.asList(createNamespaceDef2(namespaceName)));
- typeDefStore.updateTypesDef(typesDefs);
- } catch (AtlasBaseException e) {
- Assert.assertEquals(e.getAtlasErrorCode(), AtlasErrorCode.MISSING_MANDATORY_ATTRIBUTE);
+ Assert.assertEquals(e.getAtlasErrorCode(), AtlasErrorCode.APPLICABLE_ENTITY_TYPES_DELETION_NOT_SUPPORTED);
} finally {
typesDefs = existingTypeDefs;
}