Tabnine Logo
AtmosObject
Code IndexAdd Tabnine to your IDE (free)

How to use
AtmosObject
in
org.jclouds.atmos.domain

Best Java code snippets using org.jclouds.atmos.domain.AtmosObject (Showing top 20 results out of 315)

origin: jclouds/legacy-jclouds

/**
* First, calls {@link ParseSystemAndUserMetadataFromHeaders}.
* 
* Then, sets the object size based on the Content-Length header and adds the content to the
* {@link AtmosObject} result.
* 
* @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;
}
origin: jclouds/legacy-jclouds

  public Blob apply(AtmosObject from) {
   if (from == null)
     return null;
   Blob blob = blobFactory.create(object2BlobMd.apply(from));
   blob.setPayload(checkNotNull(from.getPayload(), "payload: " + from));
   HttpUtils.copy(from.getContentMetadata(), blob.getPayload().getContentMetadata());
   blob.setAllHeaders(from.getAllHeaders());
   return blob;
  }
}
origin: apache/jclouds

  @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());
  }
}
origin: jclouds/legacy-jclouds

  @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");
   return metaBinder.bindToRequest(request, object.getUserMetadata());
  }
}
origin: Nextdoor/bender

@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");
}
origin: jclouds/legacy-jclouds

  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));
   to.setUri(from.getContentMetadata().getUri());
   to.setContainer(Iterables.get(Splitter.on('/').split(from.getContentMetadata().getPath()),0));
   if (from.getAllHeaders().containsEntry("x-emc-groupacl", "other=READ"))
     to.setPublicUri(shareUrl.apply(from.getContentMetadata().getPath()));
   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;
  }
}
origin: jclouds/legacy-jclouds

  public AtmosObject apply(Blob from) {
   if (from == null)
     return null;
   AtmosObject object = blobMd2Object.apply(from.getMetadata());
   object.setPayload(checkNotNull(from.getPayload(), "payload: " + from));
   object.setAllHeaders(from.getAllHeaders());
   return object;
  }
}
origin: apache/jclouds

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);
}
origin: apache/jclouds

private static void verifyMetadata(String metadataValue, AtmosObject getBlob) {
 assertEquals(getBlob.getContentMetadata().getContentLength(), Long.valueOf(16));
 assert getBlob.getContentMetadata().getContentType().startsWith("text/plain");
 assertEquals(getBlob.getUserMetadata().getMetadata().get("Metadata"), metadataValue);
 SystemMetadata md = getBlob.getSystemMetadata();
 assertEquals(md.getSize(), 16);
 assert md.getGroupID() != null;
 assertEquals(md.getHardLinkCount(), 1);
 assert md.getInceptionTime() != null;
 assert md.getLastAccessTime() != null;
 assert md.getLastMetadataModification() != null;
 assert md.getLastUserDataModification() != null;
 assert md.getObjectID() != null;
 assertEquals(md.getObjectName(), "object");
 assert md.getPolicyName() != null;
 assertEquals(md.getType(), FileType.REGULAR);
 assert md.getUserID() != null;
}
origin: jclouds/legacy-jclouds

/**
* {@inheritDoc}
*/
@Override
public int compareTo(AtmosObject o) {
 if (getContentMetadata().getName() == null)
   return -1;
 return (this == o) ? 0 : getContentMetadata().getName().compareTo(o.getContentMetadata().getName());
}
origin: jclouds/legacy-jclouds

public void testGood() {
 AtmosObject object = injector.getInstance(AtmosObject.Factory.class).create(null);
 Payload payload = Payloads.newStringPayload("");
 object.setPayload(payload);
 object.getUserMetadata().getListableMetadata().put("apple", "bear");
 object.getUserMetadata().getListableMetadata().put("sushi", "king");
 HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
 request = binder.bindToRequest(request, object);
 assertEquals(request.getFirstHeaderOrNull("x-emc-listable-meta"), "apple=bear,sushi=king");
}
origin: jclouds/legacy-jclouds

protected void retryAndCheckSystemMetadataAndPutIfPresentReplaceStrategy(AtmosObject object) throws Exception {
 int failures = 0;
 while (true) {
   try {
    checkSystemMetadataAndPutIfPresentReplaceStrategy(object);
    break;
   } catch (ExecutionException e1) {// bug
    if (!(e1.getCause() instanceof KeyAlreadyExistsException))
      throw e1;
    else
      failures++;
   }
 }
 if (failures > 0)
   System.err.printf("%d failures create/replacing %s%n", failures,
       object.getPayload() instanceof InputStreamPayload ? "stream" : "string");
}
origin: jclouds/legacy-jclouds

private void alwaysDeleteFirstReplaceStrategy(AtmosObject object) throws Exception {
 deleteConfirmed(privateDirectory + "/" + object.getContentMetadata().getName());
 long time = System.currentTimeMillis();
 try {
   getApi().createFile(privateDirectory, object);
   System.err.printf("%s %s; %dms%n", "created", object.getPayload() instanceof InputStreamPayload ? "stream"
       : "string", System.currentTimeMillis() - time);
 } catch (Exception e) {
   String message = Throwables.getRootCause(e).getMessage();
   System.err.printf("failure %s %s; %dms: [%s]%n", "creating",
       object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis()
            - time, message);
   throw e;
 }
}
origin: apache/jclouds

@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);
}
origin: org.jclouds.api/atmos

 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);
   }
 }
}, userExecutor);
origin: jclouds/legacy-jclouds

@Test(expectedExceptions = IllegalArgumentException.class)
public void testNullContentLengthIllegal() {
 AtmosObject object = injector.getInstance(AtmosObject.Factory.class).create(null);
 Payload payload = Payloads.newStringPayload("");
 payload.getContentMetadata().setContentLength(null);
 object.setPayload(payload);
 HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
 binder.bindToRequest(request, object);
}
origin: jclouds/legacy-jclouds

 public UserMetadata apply(BlobMetadata from) {
   return blob2ObjectInfo.apply(from).getUserMetadata();
 }
}, userExecutor);
origin: Nextdoor/bender

  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));
   to.setUri(from.getContentMetadata().getUri());
   to.setContainer(Iterables.get(Splitter.on('/').split(from.getContentMetadata().getPath()), 0));
   if (from.getAllHeaders().containsEntry("x-emc-groupacl", "other=READ"))
     to.setPublicUri(shareUrl.apply(from.getContentMetadata().getPath()));
   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);
   to.setSize(from.getContentMetadata().getContentLength());
   return to;
  }
}
origin: apache/jclouds

@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");
}
origin: apache/jclouds

  public AtmosObject apply(Blob from) {
   if (from == null)
     return null;
   AtmosObject object = blobMd2Object.apply(from.getMetadata());
   object.setPayload(checkNotNull(from.getPayload(), "payload: " + from));
   object.setAllHeaders(from.getAllHeaders());
   return object;
  }
}
org.jclouds.atmos.domainAtmosObject

Most used methods

  • getContentMetadata
  • getPayload
  • getSystemMetadata
  • getUserMetadata
  • setPayload
  • getAllHeaders
  • setAllHeaders

Popular in Java

  • Parsing JSON documents to java classes using gson
  • compareTo (BigDecimal)
  • notifyDataSetChanged (ArrayAdapter)
  • getApplicationContext (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • Reference (javax.naming)
  • JCheckBox (javax.swing)
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now