Examples of MutableContentMetadata


Examples of org.jclouds.io.MutableContentMetadata

    */
   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;
   }
View Full Code Here

Examples of org.jclouds.io.MutableContentMetadata

      if (connection.getRequestProperty(USER_AGENT) == null) {
          connection.setRequestProperty(USER_AGENT, DEFAULT_USER_AGENT);
      }
      Payload payload = request.getPayload();
      if (payload != null) {
         MutableContentMetadata md = payload.getContentMetadata();
         for (Map.Entry<String,String> entry : contentMetadataCodec.toHeaders(md).entries()) {
            connection.setRequestProperty(entry.getKey(), entry.getValue());
         }
         if (chunked) {
            connection.setChunkedStreamingMode(8196);
            writePayloadToConnection(payload, "streaming", connection);
         } else {
            Long length = checkNotNull(md.getContentLength(), "payload.getContentLength");
            // TODO: remove check after moving to JDK 7.
            checkArgument(length <= Integer.MAX_VALUE,
                  "Cannot transfer 2 GB or larger chunks due to JDK 1.6 limitations." +
                  " Use chunked encoding or multi-part upload, if possible." +
                  " For more information: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6755625");
View Full Code Here

Examples of org.jclouds.io.MutableContentMetadata

import com.google.common.collect.ImmutableMap;

public class ArchiveMetadataToBlobMetadata implements Function<ArchiveMetadata, MutableBlobMetadata> {
   @Override
   public MutableBlobMetadata apply(ArchiveMetadata from) {
      MutableContentMetadata contentMetadata = new BaseMutableContentMetadata();
      contentMetadata.setContentLength(from.getSize());

      MutableBlobMetadata to = new MutableBlobMetadataImpl();
      to.setName(from.getArchiveId());
      to.setCreationDate(from.getCreationDate());
      to.setUserMetadata(ImmutableMap.<String, String>of());
View Full Code Here

Examples of org.jclouds.io.MutableContentMetadata

         payload = (in.getPayload() instanceof DelegatingPayload) ? (DelegatingPayload.class.cast(in.getPayload())
                  .getDelegate() instanceof ByteArrayPayload) ? ByteArrayPayload.class.cast(DelegatingPayload.class
                  .cast(in.getPayload()).getDelegate()) : null : null;
      try {
         if (payload == null || !(payload instanceof ByteArrayPayload)) {
            MutableContentMetadata oldMd = in.getPayload().getContentMetadata();
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            in.getPayload().writeTo(out);
            payload = (ByteArrayPayload) Payloads.calculateMD5(Payloads.newPayload(out.toByteArray()));
            HttpUtils.copy(oldMd, payload.getContentMetadata());
         } else {
View Full Code Here

Examples of org.jclouds.io.MutableContentMetadata

      if (connection.getRequestProperty(USER_AGENT) == null) {
          connection.setRequestProperty(USER_AGENT, DEFAULT_USER_AGENT);
      }
      Payload payload = request.getPayload();
      if (payload != null) {
         MutableContentMetadata md = payload.getContentMetadata();
         for (Map.Entry<String,String> entry : contentMetadataCodec.toHeaders(md).entries()) {
            connection.setRequestProperty(entry.getKey(), entry.getValue());
         }
         if (chunked) {
            connection.setChunkedStreamingMode(8196);
            writePayloadToConnection(payload, "streaming", connection);
         } else {
            Long length = checkNotNull(md.getContentLength(), "payload.getContentLength");
            // TODO: remove check after moving to JDK 7.
            checkArgument(length <= Integer.MAX_VALUE,
                  "Cannot transfer 2 GB or larger chunks due to JDK 1.6 limitations." +
                  " Use chunked encoding or multi-part upload, if possible." +
                  " For more information: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6755625");
View Full Code Here

Examples of org.jclouds.io.MutableContentMetadata

    */
   public static byte[] closeClientButKeepContentStream(PayloadEnclosing response) {
      byte[] returnVal = toByteArrayOrNull(response);
      if (returnVal != null && !response.getPayload().isRepeatable()) {
         Payload newPayload = Payloads.newByteSourcePayload(ByteSource.wrap(returnVal));
         MutableContentMetadata fromMd = response.getPayload().getContentMetadata();
         MutableContentMetadata toMd = newPayload.getContentMetadata();
         copy(fromMd, toMd);
         response.setPayload(newPayload);
      }
      return returnVal;
   }
View Full Code Here

Examples of org.jclouds.io.MutableContentMetadata

   @Override
   public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
      try {
         String xml = xmlParser.toXML(checkNotNull(input, "input"));
         request.setPayload(xml);
         MutableContentMetadata metadata = request.getPayload().getContentMetadata();
         if (contentTypeMustBeAdded(metadata)) {
            metadata.setContentType("application/xml");
         }
         return request;
      } catch (IOException ex) {
         throw new BindException(request, ex);
      }
View Full Code Here

Examples of org.jclouds.io.MutableContentMetadata

      copyPayloadMetadata(oldContent, wiredPayload);
      request.setPayload(wiredPayload);
   }

   private void copyPayloadMetadata(Payload oldContent, Payload wiredPayload) {
      MutableContentMetadata oldMd = oldContent.getContentMetadata();
      MutableContentMetadata wiredMd = wiredPayload.getContentMetadata();
      if (oldMd.getContentLength() != null)
         wiredMd.setContentLength(oldMd.getContentLength());
      wiredMd.setContentType(oldMd.getContentType());
      wiredMd.setContentMD5(oldMd.getContentMD5());
      wiredMd.setContentDisposition(oldMd.getContentDisposition());
      wiredMd.setContentEncoding(oldMd.getContentEncoding());
      wiredMd.setContentLanguage(oldMd.getContentLanguage());
      wiredMd.setExpires(oldMd.getExpires());
   }
View Full Code Here

Examples of org.jclouds.io.MutableContentMetadata

      String blobName = "test-blob";
      long oneMB = 1048576L;
      AzureBlobClient client = createMock(AzureBlobClient.class);
      PayloadSlicer slicer = createMock(PayloadSlicer.class);
      MutableBlobMetadata metadata = new MutableBlobMetadataImpl();
      MutableContentMetadata contentMetadata = new BaseMutableContentMetadata();
      contentMetadata.setContentLength(MultipartUploadStrategy.MAX_BLOCK_SIZE * 3 + oneMB);
      metadata.setName(blobName);
      metadata.setContentMetadata(contentMetadata);
      Blob blob = new BlobImpl(metadata);
      Payload payload = new StringPayload("ABCD");
      payload.setContentMetadata(contentMetadata);
View Full Code Here

Examples of org.jclouds.io.MutableContentMetadata

         apacheRequest.setEntity(entity);
      }
     
      // TODO Reproducing old behaviour exactly; ignoring Content-Type, Content-Length and Content-MD5
      Set<String> desiredHeaders = ImmutableSet.of("Content-Disposition", "Content-Encoding", "Content-Language", "Expires");
      MutableContentMetadata md = payload.getContentMetadata();
      for (Map.Entry<String,String> entry : contentMetadataCodec.toHeaders(md).entries()) {
         if (desiredHeaders.contains(entry.getKey())) {
            apacheRequest.addHeader(entry.getKey(), entry.getValue());
         }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.