private static Collection<ResourcePermissions> createEntriesForAttribute(final JsonPointer attributePointer, final JsonValue attributeValue, final Enforcer policyEnforcer) { final Collection<ResourcePermissions> result = new HashSet<>(3); if (attributeValue.isObject() && !attributeValue.isNull()) { final JsonObject jsonObject = attributeValue.asObject(); // Recursion! jsonObject.forEach( subField -> result.addAll(createEntriesForAttribute(attributePointer.addLeaf(subField.getKey()), subField.getValue(), policyEnforcer))); } else { result.add(AttributeResourcePermissions.getInstance(attributePointer, attributeValue, policyEnforcer)); } return result; }
private static Collection<ResourcePermissions> createEntriesForAttribute(final JsonPointer attributePointer, final JsonValue attributeValue, final Enforcer policyEnforcer) { final Collection<ResourcePermissions> result = new HashSet<>(3); if (attributeValue.isObject() && !attributeValue.isNull()) { final JsonObject jsonObject = attributeValue.asObject(); // Recursion! jsonObject.forEach( subField -> result.addAll(createEntriesForAttribute(attributePointer.addLeaf(subField.getKey()), subField.getValue(), policyEnforcer))); } else { result.add(AttributeResourcePermissions.getInstance(attributePointer, attributeValue, policyEnforcer)); } return result; }
private static Collection<ResourcePermissions> createEntriesForFeatureProperty(final CharSequence featureId, final JsonPointer propertyPointer, final JsonValue propertyValue, final Enforcer policyEnforcer) { final Collection<ResourcePermissions> result = new HashSet<>(3); if (propertyValue.isObject() && !propertyValue.isNull()) { final JsonObject propertyValueJsonObject = propertyValue.asObject(); // Recursion! propertyValueJsonObject.forEach(subField -> result.addAll( createEntriesForFeatureProperty(featureId, propertyPointer.addLeaf(subField.getKey()), subField.getValue(), policyEnforcer))); } else { result.add(FeaturePropertyResourcePermissions.getInstance(featureId, propertyPointer, propertyValue, policyEnforcer)); } return result; }
private static Collection<ResourcePermissions> createEntriesForFeatureProperty(final CharSequence featureId, final JsonPointer propertyPointer, final JsonValue propertyValue, final Enforcer policyEnforcer) { final Collection<ResourcePermissions> result = new HashSet<>(3); if (propertyValue.isObject() && !propertyValue.isNull()) { final JsonObject propertyValueJsonObject = propertyValue.asObject(); // Recursion! propertyValueJsonObject.forEach(subField -> result.addAll( createEntriesForFeatureProperty(featureId, propertyPointer.addLeaf(subField.getKey()), subField.getValue(), policyEnforcer))); } else { result.add(FeaturePropertyResourcePermissions.getInstance(featureId, propertyPointer, propertyValue, policyEnforcer)); } return result; }
/** * Collect list of individual property changes */ private static void collectChanges(List target, String thingId, String featureId, JsonPointer path, JsonValue value) { if (value.isObject()) { // on Object recursively collect all individual properties with concatenated property path JsonObject obj = value.asObject(); obj.forEach(c -> { collectChanges(target, thingId, featureId, path.addLeaf(c.getKey()), c.getValue()); }); } else { target.add(new History(thingId, featureId, path, value, LocalDateTime.now())); } }
/** * Maps the specified JsonObject to a {@link com.mongodb.BasicDBObject} which can be stored in MongoDB. * * @param jsonObject the object to be mapped. * @return {@code jsonObject} as BasicDBObject. * @throws NullPointerException if {@code jsonObject} is {@code null}. */ private BasicDBObject mapJsonObjectToBasicDBObject(final JsonObject jsonObject) { checkNotNull(jsonObject, "JSON object to be mapped"); final BasicDBObject result = new BasicDBObject(jsonObject.getSize()); jsonObject.forEach(jsonField -> result.put(reviseKeyName(jsonField.getKey()), mapJsonValueToJavaObject(jsonField.getValue()))); return result; }
private static List<PointerAndValue> collectFlatPointers(final JsonPointer createdPointer, final JsonField field, final List<PointerAndValue> flattenedFields) { final JsonValue fieldValue = field.getValue(); if (fieldValue.isObject()) { final JsonObject jsonObject = fieldValue.asObject(); if (!jsonObject.isEmpty()) { jsonObject.forEach(jsonField -> collectFlatPointers(createdPointer.addLeaf(jsonField.getKey()), jsonField, flattenedFields)); } else { flattenedFields.add(new PointerAndValue(createdPointer, fieldValue)); } } else { flattenedFields.add(new PointerAndValue(createdPointer, fieldValue)); } return flattenedFields; }
.orElse("?"); final JsonObjectBuilder subBuilder = JsonObject.newBuilder(); subStatusObj.forEach(subBuilder::set); if (roleStatusBuilder.build().contains(key)) { key = key + "_" + UUID.randomUUID().toString().hashCode(); .thenApply(roleStatuses -> { final JsonObjectBuilder rolesStatusBuilder = JsonFactory.newObjectBuilder(); roleStatuses.forEach(subStatusObj -> subStatusObj.forEach(rolesStatusBuilder::set));
private static JsonObject mergeJsonObjects(final JsonObject object1, final JsonObject object2) { final JsonObjectBuilder builder = JsonFactory.newObjectBuilder(); if(object1.isNull() && object2.isNull()) { return JsonFactory.nullObject(); } // add fields of jsonObject1 object1.forEach(jsonField -> { final JsonKey key = jsonField.getKey(); final JsonValue value1 = jsonField.getValue(); final Optional<JsonValue> maybeValue2 = object2.getValue(key); if (maybeValue2.isPresent()) { builder.set(key, mergeJsonValues(value1, maybeValue2.get())); } else { builder.set(jsonField); } }); // add fields of jsonObject2 not present in jsonObject0 object2.forEach(jsonField -> { if (!object1.contains(jsonField.getKey())) { builder.set(jsonField); } }); return builder.build(); }
/** * Maps the specified JsonObject to a {@link BsonDocument} which can be stored in MongoDB. * * @param jsonObject the object to be mapped. * @return {@code jsonObject} as BsonDocument. * @throws NullPointerException if {@code jsonObject} is {@code null}. */ private BsonDocument mapJsonObjectToBsonDocument(final JsonObject jsonObject) { checkNotNull(jsonObject, "JSON object to be mapped"); final BsonDocument result = new BsonDocument(); jsonObject.forEach(jsonField -> result.put(reviseKeyName(jsonField.getKey()), mapJsonValueToBsonValue(jsonField.getValue()))); return result; }
JsonObject o = v.asObject(); Map<String, Object> m = new HashMap<>(); o.forEach(e -> m.put(e.getKeyName(), getJavaValue(e.getValue()))); return m; } else {