Skip to content
Permalink
Browse files
Swift API region cleanup
Conflicts:
	openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiMockTest.java
  • Loading branch information
Jeremy Daggett committed Aug 22, 2014
1 parent d65048d commit 23a293ec59abc8fa9cd80c1ca253469525f5572d
Showing 30 changed files with 279 additions and 429 deletions.
@@ -20,10 +20,11 @@

/**
* Thrown when an object cannot be copied.
*
*
*
*
* @see {@link SwiftErrorHandler#handleError(HttpCommand, HttpResponse)}
*/
@SuppressWarnings("serial")
public class CopyObjectException extends ResourceNotFoundException {

private String sourcePath;
@@ -40,7 +40,7 @@
* <p/>
* OpenStack Object Storage is an object-based storage system that stores content and metadata
* as objects. You create, modify, and get objects and metadata using this API.
* <p/>8
* <p/>
*/
@Beta
public interface SwiftApi extends Closeable {
@@ -60,47 +60,53 @@ public interface SwiftApi extends Closeable {

@Delegate
@Path("/{containerName}")
ObjectApi getObjectApiForContainer(@EndpointParam(parser = RegionToEndpoint.class) String region,
ObjectApi getObjectApi(@EndpointParam(parser = RegionToEndpoint.class) String region,
@PathParam("containerName") String containerName);

@Delegate
@Path("/{containerName}")
StaticLargeObjectApi getStaticLargeObjectApiForContainer(
@EndpointParam(parser = RegionToEndpoint.class) String region,
StaticLargeObjectApi getStaticLargeObjectApi(@EndpointParam(parser = RegionToEndpoint.class) String region,
@PathParam("containerName") String containerName);

/**
* @deprecated Please use {@link #getAccountApi(String)} as this method will be removed in jclouds 2.0.
* @deprecated Please use {@link #getAccountApi(String)} as this method will be removed in jclouds 3.0.
*/
@Deprecated
@Delegate
AccountApi getAccountApiForRegion(@EndpointParam(parser = RegionToEndpoint.class) String region);

/**
* @deprecated Please use {@link #getBulkApi(String)} as this method will be removed in jclouds 2.0.
* @deprecated Please use {@link #getBulkApi(String)} as this method will be removed in jclouds 3.0.
*/
@Deprecated
@Delegate
BulkApi getBulkApiForRegion(@EndpointParam(parser = RegionToEndpoint.class) String region);

/**
* @deprecated Please use {@link #getContainerApi(String)} as this method will be removed in jclouds 2.0.
* @deprecated Please use {@link #getContainerApi(String)} as this method will be removed in jclouds 3.0.
*/
@Deprecated
@Delegate
ContainerApi getContainerApiForRegion(@EndpointParam(parser = RegionToEndpoint.class) String region);

/**
* @deprecated Please use {@link #getObjectApiForContainer(String)} as this method will be removed in jclouds 2.0.
* @deprecated Please use {@link #getObjectApi(String, String)} as this method will be removed in jclouds 3.0.
*/
@Deprecated
@Delegate
@Path("/{containerName}")
ObjectApi getObjectApiForRegionAndContainer(@EndpointParam(parser = RegionToEndpoint.class) String region,
@PathParam("containerName") String containerName);

/**
* @deprecated Please use {@link #getStaticLargeObjectApiForContainer(String)} as this method will be removed in jclouds 2.0.
* @deprecated Please use {@link #getStaticLargeObjectApi(String, String)} as this method
* will be removed in jclouds 3.0.
*/
@Deprecated
@Delegate
@Path("/{containerName}")
StaticLargeObjectApi getStaticLargeObjectApiForRegionAndContainer(
@EndpointParam(parser = RegionToEndpoint.class) String region,
@PathParam("containerName") String containerName);

}
@@ -42,7 +42,7 @@
* Implementation of {@link ApiMetadata} for the Swift API.
*/
public class SwiftApiMetadata extends BaseHttpApiMetadata<SwiftApi> {

@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
@@ -67,7 +67,7 @@ public static class Builder extends BaseHttpApiMetadata.Builder<SwiftApi, Builde

protected Builder() {
id("openstack-swift")
.name("OpenStack Swift Grizzly+ API")
.name("OpenStack Swift API")
.identityName("${tenantName}:${userName} or ${userName}, if your keystone supports a default tenant")
.credentialName("${password}")
.documentation(URI.create("http://docs.openstack.org/api/openstack-object-storage/1.0/content/ch_object-storage-dev-overview.html"))
@@ -85,7 +85,7 @@ protected Builder() {
.add(SwiftBlobStoreContextModule.class)
.add(SignUsingTemporaryUrls.class).build());
}

@Override
public SwiftApiMetadata build() {
return new SwiftApiMetadata(this);
@@ -60,36 +60,13 @@
*/
public class RegionScopedBlobStoreContext extends BaseView implements BlobStoreContext {

/**
* @return regions supported in this context.
*
* @deprecated Please use {{@link #getConfiguredRegions()} as this method will be removed in jclouds 2.0.
*/
@Deprecated
public Set<String> configuredRegions() {
return getConfiguredRegions();
}

/**
* @return regions supported in this context.
*/
public Set<String> getConfiguredRegions() {
return regionIds.get();
}

/**
* @param regionId
* valid region id from {@link #getConfiguredRegions()}
* @throws IllegalArgumentException
* if {@code regionId} was invalid.
*
* @deprecated Please use {{@link #getBlobStore(String)} as this method will be removed in jclouds 2.0.
*/
@Deprecated
public BlobStore blobStoreInRegion(String regionId) {
return getBlobStore(regionId);
}

/**
* @param regionId
* valid region id from {@link #getConfiguredRegions()}
@@ -101,19 +78,6 @@ public BlobStore getBlobStore(String regionId) {
return blobStore.apply(regionId);
}

/**
* @param regionId
* valid region id from {@link #getConfiguredRegions()}
* @throws IllegalArgumentException
* if {@code regionId} was invalid.
*
* @deprecated Please use {{@link #getSigner(String)} as this method will be removed in jclouds 2.0.
*/
@Deprecated
public BlobRequestSigner signerInRegion(String regionId) {
return getSigner(regionId);
}

/**
* @param regionId
* valid region id from {@link #getConfiguredRegions()}
@@ -125,20 +89,6 @@ public BlobRequestSigner getSigner(String regionId) {
return blobRequestSigner.apply(regionId);
}

/**
* @param regionId
* valid region id from {@link #getConfiguredRegions()}
* @throws IllegalArgumentException
* if {@code regionId} was invalid.
*
* @deprecated {@link AsyncBlobStore} is no longer supported. Please use {@link BlobStore} as
* this method will be removed in jclouds 2.0.
*/
@Deprecated
public AsyncBlobStore asyncBlobStoreInRegion(String regionId) {
return getAsyncBlobStore(regionId);
}

/**
* @param regionId
* valid region id from {@link #getConfiguredRegions()}
@@ -151,7 +101,7 @@ public AsyncBlobStore asyncBlobStoreInRegion(String regionId) {
@Deprecated
public AsyncBlobStore getAsyncBlobStore(String regionId) {
checkRegionId(regionId);
return new SubmissionAsyncBlobStore(blobStoreInRegion(regionId), executor);
return new SubmissionAsyncBlobStore(getBlobStore(regionId), executor);
}

protected void checkRegionId(String regionId) {
@@ -113,14 +113,14 @@ public Set<? extends Location> listAssignableLocations() {
@Override
public PageSet<? extends StorageMetadata> list() {
// TODO: there may eventually be >10k containers..
FluentIterable<StorageMetadata> containers = api.getContainerApiForRegion(regionId).list()
FluentIterable<StorageMetadata> containers = api.getContainerApi(regionId).list()
.transform(toResourceMetadata);
return new PageSetImpl<StorageMetadata>(containers, null);
}

@Override
public boolean containerExists(String container) {
Container val = api.getContainerApiForRegion(regionId).get(container);
Container val = api.getContainerApi(regionId).get(container);
containerCache.put(container, Optional.fromNullable(val));
return val != null;
}
@@ -134,9 +134,9 @@ public boolean createContainerInLocation(Location location, String container) {
public boolean createContainerInLocation(Location location, String container, CreateContainerOptions options) {
checkArgument(location == null || location.equals(region), "location must be null or %s", region);
if (options.isPublicRead()) {
return api.getContainerApiForRegion(regionId).create(container, ANYBODY_READ);
return api.getContainerApi(regionId).create(container, ANYBODY_READ);
}
return api.getContainerApiForRegion(regionId).create(container, BASIC_CONTAINER);
return api.getContainerApi(regionId).create(container, BASIC_CONTAINER);
}

private static final org.jclouds.openstack.swift.v1.options.CreateContainerOptions BASIC_CONTAINER = new org.jclouds.openstack.swift.v1.options.CreateContainerOptions();
@@ -150,7 +150,7 @@ public PageSet<? extends StorageMetadata> list(String container) {

@Override
public PageSet<? extends StorageMetadata> list(final String container, ListContainerOptions options) {
ObjectApi objectApi = api.getObjectApiForRegionAndContainer(regionId, container);
ObjectApi objectApi = api.getObjectApi(regionId, container);
ObjectList objects = objectApi.list(toListContainerOptions.apply(options));
if (objects == null) {
containerCache.put(container, Optional.<Container> absent());
@@ -191,13 +191,13 @@ public String putBlob(String container, Blob blob, PutOptions options) {
if (options.isMultipart()) {
throw new UnsupportedOperationException();
}
ObjectApi objectApi = api.getObjectApiForRegionAndContainer(regionId, container);
ObjectApi objectApi = api.getObjectApi(regionId, container);
return objectApi.put(blob.getMetadata().getName(), blob.getPayload(), metadata(blob.getMetadata().getUserMetadata()));
}

@Override
public BlobMetadata blobMetadata(String container, String name) {
SwiftObject object = api.getObjectApiForRegionAndContainer(regionId, container).get(name);
SwiftObject object = api.getObjectApi(regionId, container).get(name);
if (object == null) {
return null;
}
@@ -211,7 +211,7 @@ public Blob getBlob(String container, String key) {

@Override
public Blob getBlob(String container, String name, GetOptions options) {
ObjectApi objectApi = api.getObjectApiForRegionAndContainer(regionId, container);
ObjectApi objectApi = api.getObjectApi(regionId, container);
SwiftObject object = objectApi.get(name, toGetOptions.apply(options));
if (object == null) {
return null;
@@ -224,7 +224,7 @@ public Blob getBlob(String container, String name, GetOptions options) {

@Override
public void removeBlob(String container, String name) {
api.getObjectApiForRegionAndContainer(regionId, container).delete(name);
api.getObjectApi(regionId, container).delete(name);
}

@Override
@@ -239,13 +239,13 @@ public BlobBuilder blobBuilder(String name) {

@Override
public boolean directoryExists(String containerName, String directory) {
return api.getObjectApiForRegionAndContainer(regionId, containerName)
return api.getObjectApi(regionId, containerName)
.get(directory) != null;
}

@Override
public void createDirectory(String containerName, String directory) {
api.getObjectApiForRegionAndContainer(regionId, containerName)
api.getObjectApi(regionId, containerName)
.put(directory, directoryPayload);
}

@@ -257,12 +257,12 @@ public void createDirectory(String containerName, String directory) {

@Override
public void deleteDirectory(String containerName, String directory) {
api.getObjectApiForRegionAndContainer(regionId, containerName).delete(directory);
api.getObjectApi(regionId, containerName).delete(directory);
}

@Override
public long countBlobs(String containerName) {
Container container = api.getContainerApiForRegion(regionId).get(containerName);
Container container = api.getContainerApi(regionId).get(containerName);
// undefined if container doesn't exist, so default to zero
return container != null ? container.getObjectCount() : 0;
}
@@ -281,13 +281,13 @@ public void clearContainer(String containerName, ListContainerOptions options) {
@Override
public void deleteContainer(String container) {
clearContainer(container, recursive());
api.getContainerApiForRegion(regionId).deleteIfEmpty(container);
api.getContainerApi(regionId).deleteIfEmpty(container);
containerCache.invalidate(container);
}

@Override
public boolean deleteContainerIfEmpty(String container) {
boolean deleted = api.getContainerApiForRegion(regionId).deleteIfEmpty(container);
boolean deleted = api.getContainerApi(regionId).deleteIfEmpty(container);
if (deleted) {
containerCache.invalidate(container);
}
@@ -297,7 +297,7 @@ public boolean deleteContainerIfEmpty(String container) {
protected final LoadingCache<String, Optional<Container>> containerCache = CacheBuilder.newBuilder().build(
new CacheLoader<String, Optional<Container>>() {
public Optional<Container> load(String container) {
return Optional.fromNullable(api.getContainerApiForRegion(regionId).get(container));
return Optional.fromNullable(api.getContainerApi(regionId).get(container));
}
});

@@ -53,7 +53,7 @@ protected RegionScopedTemporaryUrlBlobSigner(@Region Supplier<Map<String, Suppli
@Assisted String regionId) {
checkNotNull(regionId, "regionId");
this.timestamp = timestamp;
this.signer = TemporaryUrlSigner.checkApiEvery(api.getAccountApiForRegion(regionId), seconds);
this.signer = TemporaryUrlSigner.checkApiEvery(api.getAccountApi(regionId), seconds);
this.storageUrl = regionToUris.get().get(regionId).get();
}

0 comments on commit 23a293e

Please sign in to comment.