From b039a8954bf026b54c9ac9632e9427e21008c9f9 Mon Sep 17 00:00:00 2001 From: Nikhil P Bonte Date: Fri, 8 Sep 2023 11:08:08 +0530 Subject: [PATCH 1/2] Add to prepare image --- .github/workflows/maven.yml | 1 + .../org/apache/atlas/web/rest/EntityREST.java | 29 ++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 3403d45797..e0cad896ad 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -26,6 +26,7 @@ on: - development - master - lineageondemand + - rawquerymigration jobs: build: diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java index cd40af9677..37a0feb7af 100644 --- a/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java +++ b/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java @@ -72,6 +72,7 @@ import java.util.function.Predicate; import java.util.stream.Collectors; +import static org.apache.commons.collections4.MapUtils.emptyIfNull; import static org.apache.atlas.AtlasErrorCode.BAD_REQUEST; import static org.apache.atlas.AtlasErrorCode.DEPRECATED_API; import static org.apache.atlas.authorize.AtlasPrivilege.*; @@ -93,6 +94,10 @@ public class EntityREST { public static final String PREFIX_ATTR_ = "attr_"; public static final String QUALIFIED_NAME = "qualifiedName"; private static final int HUNDRED_THOUSAND = 100000; + private static final int TWO_MILLION = HUNDRED_THOUSAND * 10 * 2; + private static final Set ATTRS_WITH_TWO_MILLION_LIMIT = new HashSet() {{ + add("rawQueryText"); + }}; private final AtlasTypeRegistry typeRegistry; @@ -899,15 +904,25 @@ public EntityMutationResponse createOrUpdate(AtlasEntitiesWithExtInfo entities, } public static void validateAttributeLength(final List entities) throws AtlasBaseException { - //Predicate to check attribute value exceeding length - Predicate> predicateOfAttributeLengthExceedingLimit = attribute -> - attribute.getValue() instanceof String && ((String) attribute.getValue()).length() > HUNDRED_THOUSAND; + List errorMessages = new ArrayList<>(); for (final AtlasEntity atlasEntity : entities) { - Set attributeKeys = org.apache.commons.collections4.MapUtils.emptyIfNull(atlasEntity.getAttributes()) - .entrySet().stream().filter(predicateOfAttributeLengthExceedingLimit).map(Map.Entry::getKey).collect(Collectors.toSet()); - if (!attributeKeys.isEmpty()) { - throw new AtlasBaseException("Attribute(s) " + String.join(",", attributeKeys) + " exceeds limit of "+HUNDRED_THOUSAND+" characters"); + for (Map.Entry attribute : atlasEntity.getAttributes().entrySet()) { + + if (attribute.getValue() instanceof String && ((String) attribute.getValue()).length() > HUNDRED_THOUSAND) { + + if (ATTRS_WITH_TWO_MILLION_LIMIT.contains(attribute.getKey())) { + if (((String) attribute.getValue()).length() > TWO_MILLION) { + errorMessages.add("Attribute " + attribute.getKey() + " exceeds limit of " + TWO_MILLION + " characters"); + } + } else { + errorMessages.add("Attribute " + attribute.getKey() + " exceeds limit of " + HUNDRED_THOUSAND + " characters"); + } + } + } + + if (errorMessages.size() > 0) { + throw new AtlasBaseException(AtlasType.toJson(errorMessages)); } } } From a428b48c11969b6ae25bd2fdef8b3b84325e8ef5 Mon Sep 17 00:00:00 2001 From: Nikhil P Bonte Date: Wed, 13 Sep 2023 13:11:42 +0530 Subject: [PATCH 2/2] PLT-1886 Migrate Query.rawQuery to Query.rawQueryText --- .github/workflows/maven.yml | 1 - webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java | 3 --- 2 files changed, 4 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index e0cad896ad..3403d45797 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -26,7 +26,6 @@ on: - development - master - lineageondemand - - rawquerymigration jobs: build: diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java index 37a0feb7af..7f5521e527 100644 --- a/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java +++ b/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java @@ -69,10 +69,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.*; -import java.util.function.Predicate; -import java.util.stream.Collectors; -import static org.apache.commons.collections4.MapUtils.emptyIfNull; import static org.apache.atlas.AtlasErrorCode.BAD_REQUEST; import static org.apache.atlas.AtlasErrorCode.DEPRECATED_API; import static org.apache.atlas.authorize.AtlasPrivilege.*;