public MutableBlobPropertiesImpl(BlobProperties from) {
   this.contentMetadata = new BaseMutableContentMetadata();
   this.name = from.getName();
   this.container = from.getContainer();
   this.url = from.getUrl();
   this.lastModified = from.getLastModified();
   this.eTag = from.getETag();
   this.metadata.putAll(from.getMetadata());
   HttpUtils.copy(from.getContentMetadata(), this.contentMetadata);
 }
Пример #2
0
 /**
  * Content stream may need to be read. However, we should always close the http stream.
  *
  * @throws IOException
  */
 public static byte[] closeClientButKeepContentStream(PayloadEnclosing response) {
   byte[] returnVal = toByteArrayOrNull(response);
   if (returnVal != null && !response.getPayload().isRepeatable()) {
     Payload newPayload = Payloads.newByteArrayPayload(returnVal);
     MutableContentMetadata fromMd = response.getPayload().getContentMetadata();
     MutableContentMetadata toMd = newPayload.getContentMetadata();
     copy(fromMd, toMd);
     response.setPayload(newPayload);
   }
   return returnVal;
 }
Пример #3
0
 public MutableBlobMetadata apply(AtmosObject from) {
   if (from == null) return null;
   MutableBlobMetadata to = new MutableBlobMetadataImpl();
   to.setId(from.getSystemMetadata().getObjectID());
   to.setLastModified(from.getSystemMetadata().getLastUserDataModification());
   HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata());
   to.setName(objectName.apply(from));
   if (from.getSystemMetadata().getType() == FileType.DIRECTORY) {
     to.setType(StorageType.FOLDER);
   } else {
     to.setType(StorageType.BLOB);
   }
   Map<String, String> lowerKeyMetadata = Maps.newHashMap();
   for (Entry<String, String> entry : from.getUserMetadata().getMetadata().entrySet()) {
     String key = entry.getKey().toLowerCase();
     if (!systemMetadata.contains(key)) lowerKeyMetadata.put(key, entry.getValue());
   }
   to.setUserMetadata(lowerKeyMetadata);
   return to;
 }