use of com.redhat.cloud.notifications.models.CamelProperties in project notifications-backend by RedHatInsights.
the class CamelTypeProcessor method process.
private NotificationHistory process(Notification item) {
Endpoint endpoint = item.getEndpoint();
String subType = endpoint.getSubType();
Counter processedCount = registry.counter(PROCESSED_COUNTER_NAME, "subType", subType);
processedCount.increment();
CamelProperties properties = (CamelProperties) endpoint.getProperties();
Map<String, String> metaData = new HashMap<>();
metaData.put("trustAll", String.valueOf(properties.getDisableSslVerification()));
metaData.put("url", properties.getUrl());
metaData.put("type", subType);
if (properties.getSecretToken() != null && !properties.getSecretToken().isBlank()) {
metaData.put(TOKEN_HEADER, properties.getSecretToken());
}
BasicAuthentication basicAuthentication = properties.getBasicAuthentication();
if (basicAuthentication != null && basicAuthentication.getUsername() != null && basicAuthentication.getPassword() != null) {
StringBuilder sb = new StringBuilder(basicAuthentication.getUsername());
sb.append(":");
sb.append(basicAuthentication.getPassword());
String b64 = Base64Utils.encode(sb.toString());
metaData.put("basicAuth", b64);
}
metaData.put("extras", new MapConverter().convertToDatabaseColumn(properties.getExtras()));
String originalEventId = "-not provided-";
if (item.getEvent().getId() != null) {
originalEventId = item.getEvent().getId().toString();
}
metaData.put("_originalId", originalEventId);
JsonObject payload = transformer.transform(item.getEvent().getAction());
UUID historyId = UUID.randomUUID();
JsonObject metadataAsJson = new JsonObject();
payload.put(NOTIF_METADATA_KEY, metadataAsJson);
metaData.forEach(metadataAsJson::put);
return callCamel(item, historyId, payload, originalEventId);
}
Aggregations