Search in sources :

Example 1 with Owner

use of com.google.api.services.storage.model.StorageObject.Owner in project google-cloud-java by GoogleCloudPlatform.

the class BlobInfo method toPb.

StorageObject toPb() {
    StorageObject storageObject = blobId.toPb();
    if (acl != null) {
        storageObject.setAcl(Lists.transform(acl, new Function<Acl, ObjectAccessControl>() {

            @Override
            public ObjectAccessControl apply(Acl acl) {
                return acl.toObjectPb();
            }
        }));
    }
    if (deleteTime != null) {
        storageObject.setTimeDeleted(new DateTime(deleteTime));
    }
    if (updateTime != null) {
        storageObject.setUpdated(new DateTime(updateTime));
    }
    if (createTime != null) {
        storageObject.setTimeCreated(new DateTime(createTime));
    }
    if (size != null) {
        storageObject.setSize(BigInteger.valueOf(size));
    }
    if (owner != null) {
        storageObject.setOwner(new Owner().setEntity(owner.toPb()));
    }
    if (storageClass != null) {
        storageObject.setStorageClass(storageClass.toString());
    }
    Map<String, String> pbMetadata = metadata;
    if (metadata != null && !Data.isNull(metadata)) {
        pbMetadata = Maps.newHashMapWithExpectedSize(metadata.size());
        for (Map.Entry<String, String> entry : metadata.entrySet()) {
            pbMetadata.put(entry.getKey(), firstNonNull(entry.getValue(), Data.<String>nullOf(String.class)));
        }
    }
    if (customerEncryption != null) {
        storageObject.setCustomerEncryption(customerEncryption.toPb());
    }
    storageObject.setMetadata(pbMetadata);
    storageObject.setCacheControl(cacheControl);
    storageObject.setContentEncoding(contentEncoding);
    storageObject.setCrc32c(crc32c);
    storageObject.setContentType(contentType);
    storageObject.setMd5Hash(md5);
    storageObject.setMediaLink(mediaLink);
    storageObject.setMetageneration(metageneration);
    storageObject.setContentDisposition(contentDisposition);
    storageObject.setComponentCount(componentCount);
    storageObject.setContentLanguage(contentLanguage);
    storageObject.setEtag(etag);
    storageObject.setId(generatedId);
    storageObject.setSelfLink(selfLink);
    return storageObject;
}
Also used : Function(com.google.common.base.Function) Owner(com.google.api.services.storage.model.StorageObject.Owner) StorageObject(com.google.api.services.storage.model.StorageObject) HashMap(java.util.HashMap) AbstractMap(java.util.AbstractMap) Map(java.util.Map) DateTime(com.google.api.client.util.DateTime)

Aggregations

DateTime (com.google.api.client.util.DateTime)1 StorageObject (com.google.api.services.storage.model.StorageObject)1 Owner (com.google.api.services.storage.model.StorageObject.Owner)1 Function (com.google.common.base.Function)1 AbstractMap (java.util.AbstractMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1