Created
July 16, 2019 16:42
-
-
Save jonathanvila/f9fbc393c44121213721d00ae1780963 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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