|
19 | 19 |
|
20 | 20 | #include <string_view> |
21 | 21 |
|
| 22 | +#include "api/core/FlowFile.h" |
| 23 | +#include "api/core/ProcessSession.h" |
22 | 24 | #include "google/cloud/storage/object_metadata.h" |
23 | | -#include "minifi-cpp/core/FlowFile.h" |
24 | 25 |
|
25 | 26 | namespace org::apache::nifi::minifi::extensions::gcp { |
26 | 27 |
|
@@ -50,32 +51,32 @@ constexpr std::string_view GCS_SELF_LINK_ATTR = "gcs.self.link"; |
50 | 51 | constexpr std::string_view GCS_ENCRYPTION_ALGORITHM_ATTR = "gcs.encryption.algorithm"; |
51 | 52 | constexpr std::string_view GCS_ENCRYPTION_SHA256_ATTR = "gcs.encryption.sha256"; |
52 | 53 |
|
53 | | -inline void setAttributesFromObjectMetadata(core::FlowFile& flow_file, const ::google::cloud::storage::ObjectMetadata& object_metadata) { |
54 | | - flow_file.setAttribute(GCS_BUCKET_ATTR, object_metadata.bucket()); |
55 | | - flow_file.setAttribute(GCS_OBJECT_NAME_ATTR, object_metadata.name()); |
56 | | - flow_file.setAttribute(GCS_SIZE_ATTR, std::to_string(object_metadata.size())); |
57 | | - flow_file.setAttribute(GCS_CRC32C_ATTR, object_metadata.crc32c()); |
58 | | - flow_file.setAttribute(GCS_MD5_ATTR, object_metadata.md5_hash()); |
59 | | - flow_file.setAttribute(GCS_CONTENT_ENCODING_ATTR, object_metadata.content_encoding()); |
60 | | - flow_file.setAttribute(GCS_CONTENT_LANGUAGE_ATTR, object_metadata.content_language()); |
61 | | - flow_file.setAttribute(GCS_CONTENT_DISPOSITION_ATTR, object_metadata.content_disposition()); |
62 | | - flow_file.setAttribute(GCS_CREATE_TIME_ATTR, std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(object_metadata.time_created().time_since_epoch()).count())); |
63 | | - flow_file.setAttribute(GCS_UPDATE_TIME_ATTR, std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(object_metadata.updated().time_since_epoch()).count())); |
64 | | - flow_file.setAttribute(GCS_DELETE_TIME_ATTR, std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(object_metadata.time_deleted().time_since_epoch()).count())); |
65 | | - flow_file.setAttribute(GCS_MEDIA_LINK_ATTR, object_metadata.media_link()); |
66 | | - flow_file.setAttribute(GCS_SELF_LINK_ATTR, object_metadata.self_link()); |
67 | | - flow_file.setAttribute(GCS_ETAG_ATTR, object_metadata.etag()); |
68 | | - flow_file.setAttribute(GCS_GENERATED_ID, object_metadata.id()); |
69 | | - flow_file.setAttribute(GCS_META_GENERATION, std::to_string(object_metadata.metageneration())); |
70 | | - flow_file.setAttribute(GCS_GENERATION, std::to_string(object_metadata.generation())); |
71 | | - flow_file.setAttribute(GCS_STORAGE_CLASS, object_metadata.storage_class()); |
| 54 | +inline void setAttributesFromObjectMetadata(api::core::FlowFile& flow_file, const ::google::cloud::storage::ObjectMetadata& object_metadata, api::core::ProcessSession& session) { |
| 55 | + session.setAttribute(flow_file, GCS_BUCKET_ATTR, object_metadata.bucket()); |
| 56 | + session.setAttribute(flow_file, GCS_OBJECT_NAME_ATTR, object_metadata.name()); |
| 57 | + session.setAttribute(flow_file, GCS_SIZE_ATTR, std::to_string(object_metadata.size())); |
| 58 | + session.setAttribute(flow_file, GCS_CRC32C_ATTR, object_metadata.crc32c()); |
| 59 | + session.setAttribute(flow_file, GCS_MD5_ATTR, object_metadata.md5_hash()); |
| 60 | + session.setAttribute(flow_file, GCS_CONTENT_ENCODING_ATTR, object_metadata.content_encoding()); |
| 61 | + session.setAttribute(flow_file, GCS_CONTENT_LANGUAGE_ATTR, object_metadata.content_language()); |
| 62 | + session.setAttribute(flow_file, GCS_CONTENT_DISPOSITION_ATTR, object_metadata.content_disposition()); |
| 63 | + session.setAttribute(flow_file, GCS_CREATE_TIME_ATTR, std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(object_metadata.time_created().time_since_epoch()).count())); |
| 64 | + session.setAttribute(flow_file, GCS_UPDATE_TIME_ATTR, std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(object_metadata.updated().time_since_epoch()).count())); |
| 65 | + session.setAttribute(flow_file, GCS_DELETE_TIME_ATTR, std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(object_metadata.time_deleted().time_since_epoch()).count())); |
| 66 | + session.setAttribute(flow_file, GCS_MEDIA_LINK_ATTR, object_metadata.media_link()); |
| 67 | + session.setAttribute(flow_file, GCS_SELF_LINK_ATTR, object_metadata.self_link()); |
| 68 | + session.setAttribute(flow_file, GCS_ETAG_ATTR, object_metadata.etag()); |
| 69 | + session.setAttribute(flow_file, GCS_GENERATED_ID, object_metadata.id()); |
| 70 | + session.setAttribute(flow_file, GCS_META_GENERATION, std::to_string(object_metadata.metageneration())); |
| 71 | + session.setAttribute(flow_file, GCS_GENERATION, std::to_string(object_metadata.generation())); |
| 72 | + session.setAttribute(flow_file, GCS_STORAGE_CLASS, object_metadata.storage_class()); |
72 | 73 | if (object_metadata.has_customer_encryption()) { |
73 | | - flow_file.setAttribute(GCS_ENCRYPTION_ALGORITHM_ATTR, object_metadata.customer_encryption().encryption_algorithm); |
74 | | - flow_file.setAttribute(GCS_ENCRYPTION_SHA256_ATTR, object_metadata.customer_encryption().key_sha256); |
| 74 | + session.setAttribute(flow_file, GCS_ENCRYPTION_ALGORITHM_ATTR, object_metadata.customer_encryption().encryption_algorithm); |
| 75 | + session.setAttribute(flow_file, GCS_ENCRYPTION_SHA256_ATTR, object_metadata.customer_encryption().key_sha256); |
75 | 76 | } |
76 | 77 | if (object_metadata.has_owner()) { |
77 | | - flow_file.setAttribute(GCS_OWNER_ENTITY_ATTR, object_metadata.owner().entity); |
78 | | - flow_file.setAttribute(GCS_OWNER_ENTITY_ID_ATTR, object_metadata.owner().entity_id); |
| 78 | + session.setAttribute(flow_file, GCS_OWNER_ENTITY_ATTR, object_metadata.owner().entity); |
| 79 | + session.setAttribute(flow_file, GCS_OWNER_ENTITY_ID_ATTR, object_metadata.owner().entity_id); |
79 | 80 | } |
80 | 81 | } |
81 | 82 |
|
|
0 commit comments