message.addAttributesEntry(entry.getKey(), entry.getValue()); continue;
/** * Excluding S3_BUCKET, S3_OBJECT_KEY, add all other attributes from the message body to <code>sqsMessage</code>. * @param sqsMessage The SQS message. * @param messageNode The message body. */ private void addRestMessageAttributes(Message sqsMessage, JsonNode messageNode) { Iterator<String> it = messageNode.fieldNames(); while(it.hasNext()) { String key = it.next(); if (!key.equals(S3_OBJECT_KEY) && !key.equals(S3_BUCKET_NAME)) { sqsMessage.addAttributesEntry(key, messageNode.get(key).textValue()); } } }
Entry<String, String> entry = AttributesMapEntryUnmarshaller.getInstance() .unmarshall(context); message.addAttributesEntry(entry.getKey(), entry.getValue()); continue;
@Override public CloudTrailSource getSource(Message sqsMessage) throws IOException { if (messageExtractor.getMessageText(sqsMessage).equals(CLOUD_TRAIL_VALIDATION_MESSAGE)) { sqsMessage.addAttributesEntry(SourceAttributeKeys.SOURCE_TYPE.getAttributeKey(), SourceType.CloudTrailValidationMessage.name()); return new SQSBasedSource(sqsMessage, null); } return null; } }
/** * Add the account ID attribute to the <code>sqsMessage</code> if it does not exist. * @param sqsMessage The SQS message. * @param s3ObjectKey The S3 object key. */ public static void setMessageAccountId(Message sqsMessage, String s3ObjectKey) { if (!sqsMessage.getAttributes().containsKey(SourceAttributeKeys.ACCOUNT_ID.getAttributeKey())) { String accountId = extractAccountIdFromObjectKey(s3ObjectKey); if (accountId != null) { sqsMessage.addAttributesEntry(SourceAttributeKeys.ACCOUNT_ID.getAttributeKey(), accountId); } } }
/** * As long as there is at least one CloudTrail log object: * <p> * <li>Add the CloudTrail log object key to the list.</li> * <li>Add <code>accountId</code> extracted from log object key to <code>sqsMessage</code>.</li> * <li>Add {@link SourceType#CloudTrailLog} to the <code>sqsMessage</code>.</li> * </p> * * If there is no CloudTrail log object and it is a valid CloudTrail message, CPL adds only {@link SourceType#Other} * to the <code>sqsMessage</code>. * */ private void addCloudTrailLogsAndMessageAttributes(Message sqsMessage, List<CloudTrailLog> cloudTrailLogs, JsonNode messageNode) throws IOException { SourceType sourceType = SourceType.Other; String bucketName = messageNode.get(S3_BUCKET_NAME).textValue(); List<String> objectKeys = mapper.readValue(messageNode.get(S3_OBJECT_KEY).traverse(), new TypeReference<List<String>>() {}); for (String objectKey: objectKeys) { SourceType currSourceType = sourceIdentifier.identify(objectKey); if (currSourceType == SourceType.CloudTrailLog) { cloudTrailLogs.add(new CloudTrailLog(bucketName, objectKey)); sourceType = currSourceType; LibraryUtils.setMessageAccountId(sqsMessage, objectKey); } } sqsMessage.addAttributesEntry(SourceAttributeKeys.SOURCE_TYPE.getAttributeKey(), sourceType.name()); }
sqsMessage.addAttributesEntry(SourceAttributeKeys.SOURCE_TYPE.getAttributeKey(), sourceType.name());
message.addAttributesEntry(entry.getKey(), entry.getValue()); continue;
Entry<String, String> entry = AttributesMapEntryUnmarshaller.getInstance() .unmarshall(context); message.addAttributesEntry(entry.getKey(), entry.getValue()); continue;