Examples of AtmosObject


Examples of org.jclouds.atmos.domain.AtmosObject

public class AtmosObjectName implements Function<Object, String> {
   @Override
   public String apply(Object input) {
      checkArgument(checkNotNull(input, "input") instanceof AtmosObject,
            "this function is only valid for AtmosObjects!");
      AtmosObject object = AtmosObject.class.cast(input);

      return checkNotNull(object.getContentMetadata().getName() != null ? object.getContentMetadata().getName()
            : object.getSystemMetadata().getObjectName(), "objectName");
   }
View Full Code Here

Examples of org.jclouds.atmos.domain.AtmosObject

   @Override
   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
      checkArgument(checkNotNull(input, "input") instanceof AtmosObject, "this binder is only valid for AtmosObject!");
      checkNotNull(request, "request");

      AtmosObject object = AtmosObject.class.cast(input);
      checkNotNull(object.getPayload(), "object payload");
      checkArgument(object.getPayload().getContentMetadata().getContentLength() != null,
            "contentLength must be set, streaming not supported");
      byte[] contentMD5 = object.getContentMetadata().getContentMD5();
      if (contentMD5 != null) {
         request = (R) request.toBuilder()
               .addHeader(AtmosHeaders.CHECKSUM, "MD5/0/" +
                     BaseEncoding.base16().encode(contentMD5))
               .build();
      }
      return metaBinder.bindToRequest(request, object.getUserMetadata());
   }
View Full Code Here

Examples of org.jclouds.atmos.domain.AtmosObject

   }

   public static String putBlob(final AtmosClient sync, Crypto crypto, BlobToObject blob2Object, String container,
            Blob blob, PutOptions options) {
      final String path = container + "/" + blob.getMetadata().getName();
      final AtmosObject object = blob2Object.apply(blob);
     
      try {
         sync.createFile(container, object, options);
        
      } catch (KeyAlreadyExistsException e) {
View Full Code Here

Examples of org.jclouds.atmos.domain.AtmosObject

      for (BlobMetadata md : getAllBlobMetadata.execute(containerName, options)) {
         final ListenableFuture<AtmosObject> future = client.headFile(containerName + "/" + md.getName());
         future.addListener(new Runnable() {
            public void run() {
               try {
                  AtmosObject object = future.get();
                  checkNotNull(object.getSystemMetadata(), object + " has no content metadata");
                  if (object.getSystemMetadata().getContentMD5() != null) {
                     if (Arrays.equals(toSearch, object.getSystemMetadata().getContentMD5())) {
                        queue.put(true);
                     }
                  } else {
                     logger.debug("object %s has no content md5", object.getSystemMetadata().getObjectID());
                  }
               } catch (InterruptedException e) {
                  Throwables.propagate(e);
               } catch (ExecutionException e) {
                  Throwables.propagate(e);
View Full Code Here

Examples of org.jclouds.atmos.domain.AtmosObject

   private static final Factory BLOB_FACTORY = Guice.createInjector().getInstance(AtmosObject.Factory.class);

   @Test
   public void testCorrectContentMetadataName() throws SecurityException, NoSuchMethodException {

      AtmosObject blob = BLOB_FACTORY.create(null);
      blob.getContentMetadata().setName("foo");

      assertEquals(fn.apply(blob), "foo");
   }
View Full Code Here

Examples of org.jclouds.atmos.domain.AtmosObject

   }

   @Test
   public void testCorrectSystemMetadataObjectName() throws SecurityException, NoSuchMethodException {

      AtmosObject blob = BLOB_FACTORY.create(new SystemMetadata(null, null, null, null, null, null, 0, null, "foo",
            null, 0, null, null), new UserMetadata());
      assertEquals(fn.apply(blob), "foo");
   }
View Full Code Here

Examples of org.jclouds.atmos.domain.AtmosObject

    *
    * @throws org.jclouds.http.HttpException
    */
   public AtmosObject apply(HttpResponse from) {
      checkNotNull(from, "http response");
      AtmosObject object = objectProvider.create(systemMetadataParser.apply(from), userMetadataParser.apply(from));
      object.getContentMetadata().setName(object.getSystemMetadata().getObjectName());
      object.getContentMetadata().setPath(path);
      object.getContentMetadata().setUri(uri);
      object.getAllHeaders().putAll(from.getHeaders());
      object.setPayload(from.getPayload());
      object.getContentMetadata().setContentLength(attemptToParseSizeAndRangeFromHeaders(from));
      return object;
   }
View Full Code Here

Examples of org.jclouds.atmos.domain.AtmosObject

   }

   public void test() {
      ParseObjectFromHeadersAndHttpContent parser = Guice.createInjector().getInstance(
            ParseObjectFromHeadersAndHttpContent.class);
      AtmosObject data = parser.apply(RESPONSE);

      assertEquals(data, EXPECTED);
   }
View Full Code Here

Examples of org.jclouds.atmos.domain.AtmosObject

      }
   }

   @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = { "testFileOperations" })
   public void testPutZeroLengthBlob() throws Exception {
      AtmosObject object = getApi().newObject();
      object.getContentMetadata().setName("object");
      byte[] payload = new byte[0];
      object.setPayload(Payloads.newPayload(payload));
      object.getContentMetadata().setContentLength(Long.valueOf(payload.length));
      replaceObject(object);
   }
View Full Code Here

Examples of org.jclouds.atmos.domain.AtmosObject

      return stream ? Strings2.toInputStream(in) : in;
   }

   private void createOrReplaceObject(String name, Object data, HashCode hashCode, String metadataValue) throws Exception {
      // Test PUT with string data, ETag hash, and a piece of metadata
      AtmosObject object = getApi().newObject();
      object.getContentMetadata().setName(name);
      object.setPayload(Payloads.newPayload(data));
      object.getContentMetadata().setContentLength(16l);
      object.getContentMetadata().setContentMD5(hashCode.asBytes());
      object.getContentMetadata().setContentType("text/plain");
      object.getUserMetadata().getMetadata().put("Metadata", metadataValue);
      replaceObject(object);
   }
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.