private Object getValue(ValueNode value) { if (value.isNull()) { return null; } if (value.numberType() != null) { switch (value.numberType()) { case LONG: return value.longValue(); case DOUBLE: return value.doubleValue(); case FLOAT: return value.floatValue(); case INT: return value.intValue(); case BIG_DECIMAL: return value.decimalValue(); case BIG_INTEGER: return value.bigIntegerValue(); default: return value.asText(); } } if (value.isBoolean()) { return value.asBoolean(); } return value.asText(); }
/** * Creates a new JSON-RPC request as a JSON object * * @param id request id * @param method request method * @param params request params * @return a new request as a JSON object */ @NotNull protected ObjectNode request(@NotNull ValueNode id, @NotNull String method, @NotNull JsonNode params) { if (method.isEmpty()) { throw new IllegalArgumentException("Method is not set"); } ObjectNode requestNode = mapper.createObjectNode(); requestNode.put(JSONRPC, VERSION_2_0); requestNode.put(METHOD, method); requestNode.set(PARAMS, params); if (!id.isNull()) { requestNode.set(ID, id); } return requestNode; } }
/** * {@inheritDoc} */ public Boolean visit(final NotEqualFilter filter, final JsonNode object) throws ScimException { Iterable<JsonNode> nodes = getCandidateNodes(filter.getAttributePath(), object); if (filter.getComparisonValue().isNull() && isEmpty(nodes)) { // draft-ietf-scim-core-schema section 2.4 states "Unassigned // attributes, the null value, or empty array (in the case of // a multi-valued attribute) SHALL be considered to be // equivalent in "state". return false; } for (JsonNode node : nodes) { if (JsonUtils.compareTo(node, filter.getComparisonValue(), getAttributeDefinition(filter.getAttributePath())) == 0) { return false; } } return true; }
/** * {@inheritDoc} */ public Boolean visit(final EqualFilter filter, final JsonNode object) throws ScimException { Iterable<JsonNode> nodes = getCandidateNodes(filter.getAttributePath(), object); if (filter.getComparisonValue().isNull() && isEmpty(nodes)) { // draft-ietf-scim-core-schema section 2.4 states "Unassigned // attributes, the null value, or empty array (in the case of // a multi-valued attribute) SHALL be considered to be // equivalent in "state". return true; } for (JsonNode node : nodes) { if (JsonUtils.compareTo(node, filter.getComparisonValue(), getAttributeDefinition(filter.getAttributePath())) == 0) { return true; } } return false; }
/** * {@inheritDoc} */ public Boolean visit(final NotEqualFilter filter, final JsonNode object) throws ScimException { Iterable<JsonNode> nodes = getCandidateNodes(filter.getAttributePath(), object); if (filter.getComparisonValue().isNull() && isEmpty(nodes)) { // draft-ietf-scim-core-schema section 2.4 states "Unassigned // attributes, the null value, or empty array (in the case of // a multi-valued attribute) SHALL be considered to be // equivalent in "state". return false; } for (JsonNode node : nodes) { if (JsonUtils.compareTo(node, filter.getComparisonValue(), getAttributeDefinition(filter.getAttributePath())) == 0) { return false; } } return true; }
/** * {@inheritDoc} */ public Boolean visit(final EqualFilter filter, final JsonNode object) throws ScimException { Iterable<JsonNode> nodes = getCandidateNodes(filter.getAttributePath(), object); if (filter.getComparisonValue().isNull() && isEmpty(nodes)) { // draft-ietf-scim-core-schema section 2.4 states "Unassigned // attributes, the null value, or empty array (in the case of // a multi-valued attribute) SHALL be considered to be // equivalent in "state". return true; } for (JsonNode node : nodes) { if (JsonUtils.compareTo(node, filter.getComparisonValue(), getAttributeDefinition(filter.getAttributePath())) == 0) { return true; } } return false; }