Package org.jclouds.glacier.util

Examples of org.jclouds.glacier.util.ContentRange


   @SuppressWarnings("unchecked")
   @Override
   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
      checkArgument(input instanceof ContentRange, "This binder is only valid for Payload");
      checkNotNull(request, "request");
      ContentRange range = ContentRange.class.cast(input);
      return (R) request.toBuilder().addHeader(HttpHeaders.CONTENT_RANGE, range.buildHeader()).build();
   }
View Full Code Here


   @SuppressWarnings("unchecked")
   @Override
   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
      checkArgument(input instanceof ContentRange, "This binder is only valid for ContentRange");
      checkNotNull(request, "request");
      ContentRange range = ContentRange.class.cast(input);
      return (R) request.toBuilder().addHeader("Range", "bytes=" + range.toString()).build();
   }
View Full Code Here

   @Override
   public PayloadSlice nextSlice() {
      checkNotNull(this.payload, "payload");
      long sliceLength = Math.min(getRemaining(), partSizeInMB << 20);
      Payload slicedPayload = slicer.slice(payload, copied, sliceLength);
      ContentRange range = ContentRange.build(copied, copied + sliceLength - 1);
      copied += sliceLength;
      part++;
      return new PayloadSlice(slicedPayload, range, part);
   }
View Full Code Here

      MockResponse mr = buildBaseResponse(204);
      mr.addHeader(GlacierHeaders.TREE_HASH, TREEHASH);
      server.enqueue(mr);

      long size = 1024;
      ContentRange range = ContentRange.fromPartNumber(0, size);
      Payload payload = buildPayload(1);
      payload.getContentMetadata().setContentLength(size * MiB);
      try {
         /* The client.uploadPart call should throw an HttpResponseException since the payload is smaller than expected.
          * This trick makes the test way faster.
          */
         client.uploadPart(VAULT_NAME, MULTIPART_UPLOAD_ID, range, payload);
         Assert.fail();
      } catch (HttpResponseException e) {
      }

      RecordedRequest request = server.takeRequest();
      assertEquals(request.getRequestLine(), "PUT /-/vaults/" + VAULT_NAME + "/multipart-uploads/" + MULTIPART_UPLOAD_ID + " " + HTTP);
      assertEquals(request.getHeader(HttpHeaders.CONTENT_RANGE), range.buildHeader());
      assertEquals(request.getHeader(HttpHeaders.CONTENT_LENGTH), payload.getContentMetadata().getContentLength().toString());
   }
View Full Code Here

      MockResponse mr = buildBaseResponse(202);
      mr.addHeader(HttpHeaders.LOCATION, VAULT_LOCATION + "/jobs/" + JOB_ID);
      mr.addHeader(GlacierHeaders.JOB_ID, JOB_ID);
      server.enqueue(mr);

      ContentRange range = ContentRange.fromString("2097152-4194303");
      ArchiveRetrievalJobRequest retrieval = ArchiveRetrievalJobRequest.builder()
            .archiveId(ARCHIVE_ID)
            .description(DESCRIPTION)
            .range(range)
            .build();
View Full Code Here

      mr.addHeader(HttpHeaders.CONTENT_TYPE, MediaType.JSON_UTF_8);
      mr.setBody(getResponseBody("/json/getJobOutputResponseBody.json"));
      mr.addHeader(HttpHeaders.CONTENT_LENGTH, mr.getBody().length);
      server.enqueue(mr);

      ContentRange range = ContentRange.fromString("16-32");
      client.getJobOutput(VAULT_NAME, JOB_ID, range);

      RecordedRequest request = server.takeRequest();
      assertEquals(request.getHeader("Range"), "bytes=" + range.toString());
      assertEquals(request.getRequestLine(),
              "GET /-/vaults/" + VAULT_NAME + "/jobs/" + JOB_ID + "/output " + HTTP);
   }
View Full Code Here

TOP

Related Classes of org.jclouds.glacier.util.ContentRange

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.