public int compareTo(DirectoryEntry o) { if (getObjectName() == null) return -1; return (this == o) ? 0 : getObjectName().compareTo(o.getObjectName()); }
public int compareTo(DirectoryEntry o) { if (getObjectName() == null) return -1; return (this == o) ? 0 : getObjectName().compareTo(o.getObjectName()); }
public int compareTo(DirectoryEntry o) { if (getObjectName() == null) return -1; return (this == o) ? 0 : getObjectName().compareTo(o.getObjectName()); }
public int compareTo(DirectoryEntry o) { if (getObjectName() == null) return -1; return (this == o) ? 0 : getObjectName().compareTo(o.getObjectName()); }
public int compareTo(DirectoryEntry o) { if (getObjectName() == null) return -1; return (this == o) ? 0 : getObjectName().compareTo(o.getObjectName()); }
public int compareTo(DirectoryEntry o) { if (getObjectName() == null) return -1; return (this == o) ? 0 : getObjectName().compareTo(o.getObjectName()); }
public int compareTo(DirectoryEntry o) { if (getObjectName() == null) return -1; return (this == o) ? 0 : getObjectName().compareTo(o.getObjectName()); }
public StorageMetadata apply(DirectoryEntry from) { StorageType type = from.getType() == FileType.DIRECTORY ? StorageType.FOLDER : StorageType.BLOB; if (type == StorageType.FOLDER) return new StorageMetadataImpl(type, from.getObjectID(), from.getObjectName(), defaultLocation .get(), null, null, null, null, ImmutableMap.<String,String>of()); else return new BlobMetadataImpl(from.getObjectID(), from.getObjectName(), defaultLocation.get(), null, null, null, null, ImmutableMap.<String,String>of(), null, null, new BaseMutableContentMetadata()); }
public StorageMetadata apply(DirectoryEntry from) { StorageType type = from.getType() == FileType.DIRECTORY ? StorageType.FOLDER : StorageType.BLOB; if (type == StorageType.FOLDER) return new StorageMetadataImpl(type, from.getObjectID(), from.getObjectName(), defaultLocation .get(), null, null, null, null, ImmutableMap.<String,String>of()); else return new BlobMetadataImpl(from.getObjectID(), from.getObjectName(), defaultLocation.get(), null, null, null, null, ImmutableMap.<String,String>of(), null, null, new BaseMutableContentMetadata()); }
public StorageMetadata apply(DirectoryEntry from) { StorageType type = from.getType() == FileType.DIRECTORY ? StorageType.FOLDER : StorageType.BLOB; if (type == StorageType.FOLDER) return new StorageMetadataImpl(type, from.getObjectID(), from.getObjectName(), defaultLocation .get(), null, null, null, null, ImmutableMap.<String,String>of()); else return new BlobMetadataImpl(from.getObjectID(), from.getObjectName(), defaultLocation.get(), null, null, null, null, ImmutableMap.<String,String>of(), null, null, new BaseMutableContentMetadata()); }
public StorageMetadata apply(DirectoryEntry from) { StorageType type = from.getType() == FileType.DIRECTORY ? StorageType.FOLDER : StorageType.BLOB; if (type == StorageType.FOLDER) return new StorageMetadataImpl(type, from.getObjectID(), from.getObjectName(), defaultLocation .get(), null, null, null, null, ImmutableMap.<String, String>of()); else { BlobMetadataImpl metadata = new BlobMetadataImpl(from.getObjectID(), from.getObjectName(), defaultLocation.get(), null, null, null, null, ImmutableMap.<String, String>of(), null, null, new BaseMutableContentMetadata()); MutableBlobMetadataImpl mutable = new MutableBlobMetadataImpl(metadata); mutable.setSize(from.getSize()); return mutable; } }
public StorageMetadata apply(DirectoryEntry from) { StorageType type = from.getType() == FileType.DIRECTORY ? StorageType.FOLDER : StorageType.BLOB; if (type == StorageType.FOLDER) return new StorageMetadataImpl(type, from.getObjectID(), from.getObjectName(), defaultLocation .get(), null, null, null, null, ImmutableMap.<String, String>of()); else { BlobMetadataImpl metadata = new BlobMetadataImpl(from.getObjectID(), from.getObjectName(), defaultLocation.get(), null, null, null, null, ImmutableMap.<String, String>of(), null, null, new BaseMutableContentMetadata()); MutableBlobMetadataImpl mutable = new MutableBlobMetadataImpl(metadata); mutable.setSize(from.getSize()); return mutable; } }
public StorageMetadata apply(DirectoryEntry from) { StorageType type = from.getType() == FileType.DIRECTORY ? StorageType.FOLDER : StorageType.BLOB; if (type == StorageType.FOLDER) return new StorageMetadataImpl(type, from.getObjectID(), from.getObjectName(), defaultLocation .get(), null, null, null, null, ImmutableMap.<String, String>of()); else { BlobMetadataImpl metadata = new BlobMetadataImpl(from.getObjectID(), from.getObjectName(), defaultLocation.get(), null, from.getObjectID(), null, from.getModifiedTime(), ImmutableMap.<String, String>of(), null, null, new BaseMutableContentMetadata()); MutableBlobMetadataImpl mutable = new MutableBlobMetadataImpl(metadata); mutable.setSize(from.getSize()); return mutable; } }
public StorageMetadata apply(DirectoryEntry from) { StorageType type = from.getType() == FileType.DIRECTORY ? StorageType.FOLDER : StorageType.BLOB; if (type == StorageType.FOLDER) return new StorageMetadataImpl(type, from.getObjectID(), from.getObjectName(), defaultLocation .get(), null, null, null, null, ImmutableMap.<String, String>of()); else { BlobMetadataImpl metadata = new BlobMetadataImpl(from.getObjectID(), from.getObjectName(), defaultLocation.get(), null, from.getObjectID(), null, from.getModifiedTime(), ImmutableMap.<String, String>of(), null, null, new BaseMutableContentMetadata()); MutableBlobMetadataImpl mutable = new MutableBlobMetadataImpl(metadata); mutable.setSize(from.getSize()); return mutable; } }
@Test(timeOut = 5 * 60 * 1000, dependsOnMethods = { "testCreateDirectory" }) public void testListOptions() throws Exception { createOrReplaceObject("object2", "here is my data!", "meta-value1"); createOrReplaceObject("object3", "here is my data!", "meta-value1"); createOrReplaceObject("object4", "here is my data!", "meta-value1"); BoundedSet<? extends DirectoryEntry> r2 = getApi().listDirectory(privateDirectory, ListOptions.Builder.limit(1)); assertEquals(r2.size(), 1); assert r2.getToken() != null; assertEquals(Iterables.getLast(Sets.newTreeSet(r2)).getObjectName(), "object2"); r2 = getApi().listDirectory(privateDirectory, ListOptions.Builder.token(r2.getToken())); assertEquals(r2.size(), 2); assert r2.getToken() == null; assertEquals(Iterables.getLast(Sets.newTreeSet(r2)).getObjectName(), "object4"); }
@Test(timeOut = 5 * 60 * 1000, dependsOnMethods = { "testCreateDirectory" }) public void testListOptions() throws Exception { String data = "here is my data!"; HashCode hashCode = Hashing.md5().hashString(data, UTF_8); createOrReplaceObject("object2", data, hashCode, "meta-value1"); createOrReplaceObject("object3", data, hashCode, "meta-value1"); createOrReplaceObject("object4", data, hashCode, "meta-value1"); BoundedSet<? extends DirectoryEntry> r2 = getApi().listDirectory(privateDirectory, ListOptions.Builder.limit(1)); assertEquals(r2.size(), 1); assert r2.getToken() != null; assertEquals(Iterables.getLast(Sets.newTreeSet(r2)).getObjectName(), "object2"); r2 = getApi().listDirectory(privateDirectory, ListOptions.Builder.token(r2.getToken())); assertEquals(r2.size(), 2); assert r2.getToken() == null; assertEquals(Iterables.getLast(Sets.newTreeSet(r2)).getObjectName(), "object4"); }
@Test(timeOut = 5 * 60 * 1000) public void testCreateDirectory() throws Exception { boolean created = false; while (!created) { privateDirectory = containerPrefix + new SecureRandom().nextInt(); try { created = getApi().createDirectory(privateDirectory) != null; } catch (UndeclaredThrowableException e) { HttpResponseException htpe = (HttpResponseException) e.getCause().getCause(); if (htpe.getResponse().getStatusCode() == 409) continue; throw e; } } BoundedSet<? extends DirectoryEntry> response = getApi().listDirectories(); for (DirectoryEntry id : response) { BoundedSet<? extends DirectoryEntry> r2 = getApi().listDirectory(id.getObjectName()); assert r2 != null; } }
@Test(timeOut = 5 * 60 * 1000) public void testCreateDirectory() throws Exception { boolean created = false; while (!created) { privateDirectory = containerPrefix + new SecureRandom().nextInt(); try { created = getApi().createDirectory(privateDirectory) != null; } catch (UndeclaredThrowableException e) { HttpResponseException htpe = (HttpResponseException) e.getCause().getCause(); if (htpe.getResponse().getStatusCode() == 409) continue; throw e; } } BoundedSet<? extends DirectoryEntry> response = getApi().listDirectories(); for (DirectoryEntry id : response) { BoundedSet<? extends DirectoryEntry> r2 = getApi().listDirectory(id.getObjectName()); assert r2 != null; } // subsequent creation should fail assertNull(getApi().createDirectory(privateDirectory)); }