use of com.amazonaws.services.clouddirectory.model.ListIndexResult in project cas by apereo.
the class DefaultCloudDirectoryRepository method getUserInfoFromIndexResult.
private Map<String, Object> getUserInfoFromIndexResult(final ListIndexResult indexResult) {
final IndexAttachment attachment = indexResult.getIndexAttachments().stream().findFirst().orElse(null);
if (attachment != null) {
final String identifier = attachment.getObjectIdentifier();
final ListObjectAttributesRequest listObjectAttributesRequest = CloudDirectoryUtils.getListObjectAttributesRequest(cloudDirectoryProperties.getDirectoryArn(), identifier);
final ListObjectAttributesResult attributesResult = amazonCloudDirectory.listObjectAttributes(listObjectAttributesRequest);
if (attributesResult != null && attributesResult.getAttributes() != null) {
return attributesResult.getAttributes().stream().map(a -> {
Object value = null;
final TypedAttributeValue attributeValue = a.getValue();
LOGGER.debug("Examining attribute [{}]", a);
if (StringUtils.isNotBlank(attributeValue.getNumberValue())) {
value = attributeValue.getNumberValue();
} else if (attributeValue.getDatetimeValue() != null) {
value = DateTimeUtils.zonedDateTimeOf(attributeValue.getDatetimeValue()).toString();
} else if (attributeValue.getBooleanValue() != null) {
value = attributeValue.getBooleanValue().toString();
} else if (attributeValue.getBinaryValue() != null) {
value = new String(attributeValue.getBinaryValue().array(), StandardCharsets.UTF_8);
} else if (StringUtils.isNotBlank(attributeValue.getStringValue())) {
value = attributeValue.getStringValue();
}
return Pair.of(a.getKey().getName(), value);
}).filter(p -> p.getValue() != null).collect(Collectors.toMap(Pair::getKey, Pair::getValue));
}
}
return null;
}
Aggregations