169 logger.debug(
"Going to process JsonNode path " + fieldPath +
" on data " + baseNode);
170 if (baseNode != null) {
174 String currentFieldName = fieldPath;
176 currentFieldName = fieldPath.substring(0, idx).trim();
177 if (currentFieldName.isEmpty()) {
178 logger.debug(
"JSON path is invalid " + fieldPath);
183 String currentNodeName = currentFieldName;
185 if (currentFieldName.endsWith(
"]")) {
186 int bi = currentFieldName.indexOf(
"[");
188 logger.debug(
"Invalid array index construct in " + currentFieldName);
192 String is = currentFieldName.substring(bi+1, currentFieldName.length() - 1).trim();
193 arrayIndex = Integer.parseInt(is);
194 }
catch (Exception e) {
195 logger.debug(
"Invalid array index construct in " + currentFieldName);
198 currentNodeName = currentFieldName.substring(0,bi).trim();
201 JsonNode currentNode = baseNode.get(currentNodeName);
202 if (arrayIndex > -1 && currentNode.isArray()) {
203 logger.debug(
"Going to take array node at index " + arrayIndex);
204 currentNode = currentNode.get(arrayIndex);
207 if (currentNode == null) {
208 logger.debug(
"JsonNode not found for name " + currentFieldName);
213 if (currentNode.isArray()) {
214 List<String> values =
new ArrayList<>();
215 for (JsonNode childNode : currentNode) {
216 if (childNode.isTextual()) {
217 values.add(childNode.textValue());
219 logger.warn(
"JsonNode in array is not text value " + childNode);
222 if (values.isEmpty()) {
225 return arrayIndex == idx? values : null;
227 if (!currentNode.isValueNode() || currentNode.isNull()) {
228 logger.debug(
"JsonNode is not value node for name " + currentFieldName);
231 String ret = currentNode.asText();
232 if (ret != null && !ret.trim().isEmpty())
235 return getJsonValue(currentNode, fieldPath.substring(idx + 1));
static Object getJsonValue(IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)
Definition: AbstractJsonUserAttributeMapper.java:143
static final String JSON_PATH_DELIMITER
Definition: AbstractJsonUserAttributeMapper.java:48
static final Logger logger
Definition: AbstractJsonUserAttributeMapper.java:44