private Set<JsonField> calculateThresholdViolations(final String featureId, final FeatureProperties featureProperties) { return featureProperties.stream() .filter(field -> violatesThreshold( field.getKey().asPointer(), field.getValue(), featurePropertyOverhead(featureId), MAX_INDEX_CONTENT_LENGTH)) .collect(Collectors.toSet()); }
private Set<JsonField> calculateThresholdViolations(final Attributes attributes) { return attributes .stream() .filter(field -> violatesThreshold(field.getKey().asPointer(), field.getValue(), attributeOverhead(), MAX_INDEX_CONTENT_LENGTH)) .collect(Collectors.toSet()); }
private Set<JsonField> calculateThresholdViolations(final String featureId, final FeatureProperties featureProperties) { return featureProperties.stream() .filter(field -> violatesThreshold( field.getKey().asPointer(), field.getValue(), featurePropertyOverhead(featureId), MAX_INDEX_CONTENT_LENGTH)) .collect(Collectors.toSet()); }
private Set<JsonField> calculateThresholdViolations(final Attributes attributes) { return attributes .stream() .filter(field -> violatesThreshold(field.getKey().asPointer(), field.getValue(), attributeOverhead(), MAX_INDEX_CONTENT_LENGTH)) .collect(Collectors.toSet()); }
/** * Converts the specified char sequence to a {@link JsonPointer} which is guaranteed to be not empty. * * @param keyOrPointer a string representation of a JSON pointer or a JsonKey. * @return the pointer. * @throws NullPointerException if {@code keyOrPointer} is {@code null}. * @throws IllegalArgumentException if {@code keyOrPointer} would lead to an empty JsonPointer. */ static JsonPointer getNonEmptyPointer(final CharSequence keyOrPointer) { requireNonNull(keyOrPointer, "The key or pointer char sequence must not be null!"); final JsonPointer result; if (isPointer(keyOrPointer)) { result = JsonFactory.newPointer(keyOrPointer); } else { final JsonKey jsonKey = JsonFactory.newKey(keyOrPointer); result = jsonKey.asPointer(); } if (result.isEmpty()) { throw new IllegalArgumentException("The key or pointer must not be empty!"); } return result; }
/** * Converts the specified char sequence to a {@link JsonPointer} which is guaranteed to be not empty. * * @param keyOrPointer a string representation of a JSON pointer or a JsonKey. * @return the pointer. * @throws NullPointerException if {@code keyOrPointer} is {@code null}. * @throws IllegalArgumentException if {@code keyOrPointer} would lead to an empty JsonPointer. */ static JsonPointer getNonEmptyPointer(final CharSequence keyOrPointer) { requireNonNull(keyOrPointer, "The key or pointer char sequence must not be null!"); final JsonPointer result; if (isPointer(keyOrPointer)) { result = newPointer(keyOrPointer); } else { final JsonKey jsonKey = newKey(keyOrPointer); result = jsonKey.asPointer(); } if (result.isEmpty()) { throw new IllegalArgumentException("The key or pointer must not be empty!"); } return result; }
private FeatureProperties fixViolations(final String featureId, final Set<JsonField> exceededProps, final FeatureProperties featureProperties) { final FeaturePropertiesBuilder featurePropertiesBuilder = featureProperties.toBuilder(); exceededProps.forEach( jsonField -> { final JsonValue restrictedValue = fixViolation( jsonField.getKey().asPointer(), jsonField.getValue(), featurePropertyOverhead(featureId), MAX_INDEX_CONTENT_LENGTH); featurePropertiesBuilder.set(jsonField.getKey().asPointer(), restrictedValue); }); return featurePropertiesBuilder.build(); }
private FeatureProperties fixViolations(final String featureId, final Set<JsonField> exceededProps, final FeatureProperties featureProperties) { final FeaturePropertiesBuilder featurePropertiesBuilder = featureProperties.toBuilder(); exceededProps.forEach( jsonField -> { final JsonValue restrictedValue = fixViolation( jsonField.getKey().asPointer(), jsonField.getValue(), featurePropertyOverhead(featureId), MAX_INDEX_CONTENT_LENGTH); featurePropertiesBuilder.set(jsonField.getKey().asPointer(), restrictedValue); }); return featurePropertiesBuilder.build(); }
private Attributes fixViolations(final Set<JsonField> exceededAttributes, final Attributes attributes) { final AttributesBuilder builder = attributes.toBuilder(); exceededAttributes.forEach(field -> builder.set( field.getKey().toString(), fixViolation(field.getKey().asPointer(), field.getValue(), attributeOverhead(), MAX_INDEX_CONTENT_LENGTH))); return builder.build(); }
private Attributes fixViolations(final Set<JsonField> exceededAttributes, final Attributes attributes) { final AttributesBuilder builder = attributes.toBuilder(); exceededAttributes.forEach(field -> builder.set( field.getKey().toString(), fixViolation(field.getKey().asPointer(), field.getValue(), attributeOverhead(), MAX_INDEX_CONTENT_LENGTH))); return builder.build(); }
@Override public JsonObject buildJsonView( final ResourceKey resourceKey, final Iterable<JsonField> jsonFields, final AuthorizationContext authorizationContext, final Permissions permissions) { checkResourceKey(resourceKey); checkNotNull(jsonFields, "JSON fields"); checkPermissions(permissions); final Collection<String> authorizationSubjectIds = getAuthorizationSubjectIds(authorizationContext); final EffectedResources effectedResources = getGrantedAndRevokedSubResource( JsonFactory.newPointer(ROOT_RESOURCE), resourceKey.getResourceType(), authorizationSubjectIds, permissions); if (jsonFields instanceof JsonObject && ((JsonObject) jsonFields).isNull()) { return JsonFactory.nullObject(); } final List<PointerAndValue> flatPointers = new ArrayList<>(); jsonFields.forEach(jsonField -> collectFlatPointers(jsonField.getKey().asPointer(), jsonField, flatPointers)); final Set<JsonPointer> grantedResources = extractJsonPointers(effectedResources.getGrantedResources()); final Set<JsonPointer> revokedResources = extractJsonPointers(effectedResources.getRevokedResources()); final JsonPointer resourcePath = resourceKey.getResourcePath(); final List<PointerAndValue> prefixedPointers = flatPointers.stream() .map(pv -> new PointerAndValue(resourcePath.append(pv.pointer), pv.value)) .collect(Collectors.toList()); return filterEntries(prefixedPointers, grantedResources, revokedResources, resourcePath); }