Package org.jclouds.io

Examples of org.jclouds.io.MutableContentMetadata


      }
   }

   protected void assertContentHeadersEqual(HttpRequest request, String contentType, String contentDispositon,
         String contentEncoding, String contentLanguage, Long length, byte[] contentMD5, Date expires) {
      MutableContentMetadata md = request.getPayload().getContentMetadata();
      if (request.getFirstHeaderOrNull(TRANSFER_ENCODING) == null) {
         assertEquals(md.getContentLength(), length);
      } else {
         assertEquals(request.getFirstHeaderOrNull(TRANSFER_ENCODING), "chunked");
         assert md.getContentLength() == null || md.getContentLength().equals(length);
      }
      assertEquals(md.getContentType(), contentType);
      assertEquals(md.getContentDisposition(), contentDispositon);
      assertEquals(md.getContentEncoding(), contentEncoding);
      assertEquals(md.getContentLanguage(), contentLanguage);
      assertEquals(md.getContentMD5(), contentMD5);
      assertEquals(md.getExpires(), expires);
   }
View Full Code Here


      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

      }
   }

   protected void assertContentHeadersEqual(HttpRequest request, String contentType, String contentDispositon,
         String contentEncoding, String contentLanguage, Long length, byte[] contentMD5, Date expires) {
      MutableContentMetadata md = request.getPayload().getContentMetadata();
      if (request.getFirstHeaderOrNull(TRANSFER_ENCODING) == null) {
         assertEquals(md.getContentLength(), length);
      } else {
         assertEquals(request.getFirstHeaderOrNull(TRANSFER_ENCODING), "chunked");
         assert md.getContentLength() == null || md.getContentLength().equals(length);
      }
      assertEquals(md.getContentType(), contentType);
      assertEquals(md.getContentDisposition(), contentDispositon);
      assertEquals(md.getContentEncoding(), contentEncoding);
      assertEquals(md.getContentLanguage(), contentLanguage);
      assertEquals(md.getContentMD5(), contentMD5);
      assertEquals(md.getExpires(), expires);
   }
View Full Code Here

    */
   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

      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

      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

   @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

         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

      }
   }

   protected void assertContentHeadersEqual(HttpRequest request, String contentType, String contentDispositon,
         String contentEncoding, String contentLanguage, Long length, byte[] contentMD5, Date expires) {
      MutableContentMetadata md = request.getPayload().getContentMetadata();
      if (request.getFirstHeaderOrNull(TRANSFER_ENCODING) == null) {
         assertEquals(md.getContentLength(), length);
      } else {
         assertEquals(request.getFirstHeaderOrNull(TRANSFER_ENCODING), "chunked");
         assert md.getContentLength() == null || md.getContentLength().equals(length);
      }
      assertEquals(md.getContentType(), contentType);
      assertEquals(md.getContentDisposition(), contentDispositon);
      assertEquals(md.getContentEncoding(), contentEncoding);
      assertEquals(md.getContentLanguage(), contentLanguage);
      assertEquals(md.getContentMD5(), contentMD5);
      assertEquals(md.getExpires(), expires);
   }
View Full Code Here

    */
   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

TOP

Related Classes of org.jclouds.io.MutableContentMetadata

Copyright © 2018 www.massapicom. 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.