Skip to content

Commit b039a89

Browse files
committed
Add to prepare image
1 parent 4a47ac3 commit b039a89

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

.github/workflows/maven.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ on:
2626
- development
2727
- master
2828
- lineageondemand
29+
- rawquerymigration
2930

3031
jobs:
3132
build:

webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
import java.util.function.Predicate;
7373
import java.util.stream.Collectors;
7474

75+
import static org.apache.commons.collections4.MapUtils.emptyIfNull;
7576
import static org.apache.atlas.AtlasErrorCode.BAD_REQUEST;
7677
import static org.apache.atlas.AtlasErrorCode.DEPRECATED_API;
7778
import static org.apache.atlas.authorize.AtlasPrivilege.*;
@@ -93,6 +94,10 @@ public class EntityREST {
9394
public static final String PREFIX_ATTR_ = "attr_";
9495
public static final String QUALIFIED_NAME = "qualifiedName";
9596
private static final int HUNDRED_THOUSAND = 100000;
97+
private static final int TWO_MILLION = HUNDRED_THOUSAND * 10 * 2;
98+
private static final Set<String> ATTRS_WITH_TWO_MILLION_LIMIT = new HashSet<String>() {{
99+
add("rawQueryText");
100+
}};
96101

97102

98103
private final AtlasTypeRegistry typeRegistry;
@@ -899,15 +904,25 @@ public EntityMutationResponse createOrUpdate(AtlasEntitiesWithExtInfo entities,
899904
}
900905

901906
public static void validateAttributeLength(final List<AtlasEntity> entities) throws AtlasBaseException {
902-
//Predicate to check attribute value exceeding length
903-
Predicate<Map.Entry<String, Object>> predicateOfAttributeLengthExceedingLimit = attribute ->
904-
attribute.getValue() instanceof String && ((String) attribute.getValue()).length() > HUNDRED_THOUSAND;
907+
List<String> errorMessages = new ArrayList<>();
905908

906909
for (final AtlasEntity atlasEntity : entities) {
907-
Set<String> attributeKeys = org.apache.commons.collections4.MapUtils.emptyIfNull(atlasEntity.getAttributes())
908-
.entrySet().stream().filter(predicateOfAttributeLengthExceedingLimit).map(Map.Entry::getKey).collect(Collectors.toSet());
909-
if (!attributeKeys.isEmpty()) {
910-
throw new AtlasBaseException("Attribute(s) " + String.join(",", attributeKeys) + " exceeds limit of "+HUNDRED_THOUSAND+" characters");
910+
for (Map.Entry<String, Object> attribute : atlasEntity.getAttributes().entrySet()) {
911+
912+
if (attribute.getValue() instanceof String && ((String) attribute.getValue()).length() > HUNDRED_THOUSAND) {
913+
914+
if (ATTRS_WITH_TWO_MILLION_LIMIT.contains(attribute.getKey())) {
915+
if (((String) attribute.getValue()).length() > TWO_MILLION) {
916+
errorMessages.add("Attribute " + attribute.getKey() + " exceeds limit of " + TWO_MILLION + " characters");
917+
}
918+
} else {
919+
errorMessages.add("Attribute " + attribute.getKey() + " exceeds limit of " + HUNDRED_THOUSAND + " characters");
920+
}
921+
}
922+
}
923+
924+
if (errorMessages.size() > 0) {
925+
throw new AtlasBaseException(AtlasType.toJson(errorMessages));
911926
}
912927
}
913928
}

0 commit comments

Comments
 (0)