Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jonathanvila/f9fbc393c44121213721d00ae1780963 to your computer and use it in GitHub Desktop.
Save jonathanvila/f9fbc393c44121213721d00ae1780963 to your computer and use it in GitHub Desktop.
public String getRHIdentity(String x_rh_identity_json, String filename, Map<String, Object> headers) throws IOException {
RHIdentity rhidentity;
String identity_json_decoded = new String(Base64.getDecoder().decode(x_rh_identity_json));
if (x_rh_identity_json != null) {
rhidentity = new ObjectMapper().reader().withRootName("identity").readValue(new JsonFactory().createParser(identity_json_decoded), RHIdentity.class);
} else {
rhidentity = new RHIdentity();
}
// we add all properties defined on the Insights Properties, that we should have as Headers of the message
insightsProperties.forEach(e -> rhidentity.getInternal().put(e, ((Map<String,Object>) headers.get("MA_metadata")).get(e).toString()));
rhidentity.getInternal().put("filename", filename);
String rhIdentity_json = "";
try {
rhIdentity_json = new ObjectMapper().writer().withRootName("identity").writeValueAsString(RHIdentity.builder()
.account_number(accountNumber)
.internal(rhidentity.getInternal())
.build());
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return Base64.getEncoder().encodeToString(rhIdentity_json.getBytes());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment