Java Code Examples for com.google.cloud.storage.Blob#getOwner()
The following examples show how to use
com.google.cloud.storage.Blob#getOwner() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListGCSBucket.java From nifi with Apache License 2.0 | 4 votes |
private Record createRecordForListing(final Blob blob) { final Map<String, Object> values = new HashMap<>(); values.put(BUCKET, blob.getBucket()); values.put(NAME, blob.getName()); values.put(SIZE, blob.getSize()); values.put(CACHE_CONTROL, blob.getCacheControl()); values.put(COMPONENT_COUNT, blob.getComponentCount()); values.put(CONTENT_DISPOSITION, blob.getContentDisposition()); values.put(CONTENT_ENCODING, blob.getContentEncoding()); values.put(CONTENT_LANGUAGE, blob.getContentLanguage()); values.put(CRC32C, blob.getCrc32c()); values.put(CREATE_TIME, blob.getCreateTime() == null ? null : new Timestamp(blob.getCreateTime())); values.put(UPDATE_TIME, blob.getUpdateTime() == null ? null : new Timestamp(blob.getUpdateTime())); final BlobInfo.CustomerEncryption encryption = blob.getCustomerEncryption(); if (encryption != null) { values.put(ENCRYPTION_ALGORITHM, encryption.getEncryptionAlgorithm()); values.put(ENCRYPTION_KEY_SHA256, encryption.getKeySha256()); } values.put(ETAG, blob.getEtag()); values.put(GENERATED_ID, blob.getGeneratedId()); values.put(GENERATION, blob.getGeneration()); values.put(MD5, blob.getMd5()); values.put(MEDIA_LINK, blob.getMediaLink()); values.put(METAGENERATION, blob.getMetageneration()); final Acl.Entity owner = blob.getOwner(); if (owner != null) { if (owner instanceof Acl.User) { values.put(OWNER, ((Acl.User) owner).getEmail()); values.put(OWNER_TYPE, "user"); } else if (owner instanceof Acl.Group) { values.put(OWNER, ((Acl.Group) owner).getEmail()); values.put(OWNER_TYPE, "group"); } else if (owner instanceof Acl.Domain) { values.put(OWNER, ((Acl.Domain) owner).getDomain()); values.put(OWNER_TYPE, "domain"); } else if (owner instanceof Acl.Project) { values.put(OWNER, ((Acl.Project) owner).getProjectId()); values.put(OWNER_TYPE, "project"); } } values.put(URI, blob.getSelfLink()); return new MapRecord(RECORD_SCHEMA, values); }
Example 2
Source File: StorageAttributes.java From nifi with Apache License 2.0 | 4 votes |
public static Map<String, String> createAttributes(final Blob blob) { final Map<String, String> attributes = new HashMap<>(); addAttribute(attributes, BUCKET_ATTR, blob.getBucket()); addAttribute(attributes, KEY_ATTR, blob.getName()); addAttribute(attributes, SIZE_ATTR, blob.getSize()); addAttribute(attributes, CACHE_CONTROL_ATTR, blob.getCacheControl()); addAttribute(attributes, COMPONENT_COUNT_ATTR, blob.getComponentCount()); addAttribute(attributes, CONTENT_DISPOSITION_ATTR, blob.getContentDisposition()); addAttribute(attributes, CONTENT_ENCODING_ATTR, blob.getContentEncoding()); addAttribute(attributes, CONTENT_LANGUAGE_ATTR, blob.getContentLanguage()); addAttribute(attributes, CoreAttributes.MIME_TYPE.key(), blob.getContentType()); addAttribute(attributes, CRC32C_ATTR, blob.getCrc32c()); if (blob.getCustomerEncryption() != null) { final BlobInfo.CustomerEncryption encryption = blob.getCustomerEncryption(); addAttribute(attributes, ENCRYPTION_ALGORITHM_ATTR, encryption.getEncryptionAlgorithm()); addAttribute(attributes, ENCRYPTION_SHA256_ATTR, encryption.getKeySha256()); } addAttribute(attributes, ETAG_ATTR, blob.getEtag()); addAttribute(attributes, GENERATED_ID_ATTR, blob.getGeneratedId()); addAttribute(attributes, GENERATION_ATTR, blob.getGeneration()); addAttribute(attributes, MD5_ATTR, blob.getMd5()); addAttribute(attributes, MEDIA_LINK_ATTR, blob.getMediaLink()); addAttribute(attributes, METAGENERATION_ATTR, blob.getMetageneration()); if (blob.getOwner() != null) { final Acl.Entity entity = blob.getOwner(); if (entity instanceof Acl.User) { addAttribute(attributes, OWNER_ATTR, ((Acl.User) entity).getEmail()); addAttribute(attributes, OWNER_TYPE_ATTR, "user"); } else if (entity instanceof Acl.Group) { addAttribute(attributes, OWNER_ATTR, ((Acl.Group) entity).getEmail()); addAttribute(attributes, OWNER_TYPE_ATTR, "group"); } else if (entity instanceof Acl.Domain) { addAttribute(attributes, OWNER_ATTR, ((Acl.Domain) entity).getDomain()); addAttribute(attributes, OWNER_TYPE_ATTR, "domain"); } else if (entity instanceof Acl.Project) { addAttribute(attributes, OWNER_ATTR, ((Acl.Project) entity).getProjectId()); addAttribute(attributes, OWNER_TYPE_ATTR, "project"); } } addAttribute(attributes, URI_ATTR, blob.getSelfLink()); addAttribute(attributes, CoreAttributes.FILENAME.key(), blob.getName()); addAttribute(attributes, CREATE_TIME_ATTR, blob.getCreateTime()); addAttribute(attributes, UPDATE_TIME_ATTR, blob.getUpdateTime()); return attributes; }