diff options
author | seshukm <seshu.kumar.m@huawei.com> | 2018-07-25 20:02:19 +0800 |
---|---|---|
committer | seshukm <seshu.kumar.m@huawei.com> | 2018-07-25 20:02:19 +0800 |
commit | 77a48e21e84a158cab36aee2b9d3f1c622057aa0 (patch) | |
tree | 9af10c64d892978730380f5ecbf1e463517c64e8 /swift-client/src | |
parent | 0bf2ba5a56322d1a7e238716832cca71c8980880 (diff) |
basic code refactoring of swift-client module
Issue-ID: SO-729
Change-Id: I33ae9f89327458394fbc33952d125dca303d0bf3
Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
Diffstat (limited to 'swift-client/src')
4 files changed, 218 insertions, 218 deletions
diff --git a/swift-client/src/main/java/com/woorea/openstack/swift/Swift.java b/swift-client/src/main/java/com/woorea/openstack/swift/Swift.java index 959695b..8ae3200 100644 --- a/swift-client/src/main/java/com/woorea/openstack/swift/Swift.java +++ b/swift-client/src/main/java/com/woorea/openstack/swift/Swift.java @@ -23,27 +23,27 @@ import com.woorea.openstack.swift.api.AccountResource; import com.woorea.openstack.swift.api.ContainersResource; public class Swift extends OpenStackClient { - - private final AccountResource ACCOUNT; - - private final ContainersResource CONTAINERS; - - public Swift(String endpoint, OpenStackClientConnector connector) { - super(endpoint, connector); - CONTAINERS = new ContainersResource(this); - ACCOUNT = new AccountResource(this); - } - - public Swift(String endpoint) { - this(endpoint, null); - } - - public ContainersResource containers() { - return CONTAINERS; - } - - public AccountResource account() { - return ACCOUNT; - } + + private final AccountResource ACCOUNT; + + private final ContainersResource CONTAINERS; + + public Swift(String endpoint, OpenStackClientConnector connector) { + super(endpoint, connector); + CONTAINERS = new ContainersResource(this); + ACCOUNT = new AccountResource(this); + } + + public Swift(String endpoint) { + this(endpoint, null); + } + + public ContainersResource containers() { + return CONTAINERS; + } + + public AccountResource account() { + return ACCOUNT; + } } diff --git a/swift-client/src/main/java/com/woorea/openstack/swift/api/AccountResource.java b/swift-client/src/main/java/com/woorea/openstack/swift/api/AccountResource.java index e09e467..7efd22a 100644 --- a/swift-client/src/main/java/com/woorea/openstack/swift/api/AccountResource.java +++ b/swift-client/src/main/java/com/woorea/openstack/swift/api/AccountResource.java @@ -20,19 +20,19 @@ import com.woorea.openstack.base.client.OpenStackClient; import com.woorea.openstack.base.client.OpenStackRequest; public class AccountResource { - - private final OpenStackClient CLIENT; - - public AccountResource(OpenStackClient client) { - CLIENT = client; - } + + private final OpenStackClient CLIENT; + + public AccountResource(OpenStackClient client) { + CLIENT = client; + } - public class ShowAccount extends OpenStackRequest<Void> { + public class ShowAccount extends OpenStackRequest<Void> { - public ShowAccount() { -// return target.request(MediaType.APPLICATION_JSON).head(); - } + public ShowAccount() { +// return target.request(MediaType.APPLICATION_JSON).head(); + } - } + } } diff --git a/swift-client/src/main/java/com/woorea/openstack/swift/api/ContainerResource.java b/swift-client/src/main/java/com/woorea/openstack/swift/api/ContainerResource.java index 5abb086..23a2d0d 100644 --- a/swift-client/src/main/java/com/woorea/openstack/swift/api/ContainerResource.java +++ b/swift-client/src/main/java/com/woorea/openstack/swift/api/ContainerResource.java @@ -26,134 +26,134 @@ import com.woorea.openstack.swift.model.ObjectDownload; import com.woorea.openstack.swift.model.ObjectForUpload; public class ContainerResource { - - private final OpenStackClient CLIENT; - - private String container; - - public ContainerResource(OpenStackClient client, String container) { - CLIENT = client; - this.container = container; - } - - public List list() { - return new List(container, null); - } - - public CreateDirectory createDirectory(String path) { - return new CreateDirectory(container, path); - } - - public Show show(String path) { - return new Show(container, path); - } - - public Upload upload(ObjectForUpload objectForUpload) { - return new Upload(objectForUpload); - } - - public Download download(String path) { - return new Download(container, path); - } - - public Delete delete(String path) { - return new Delete(container, path); - } - - public class List extends OpenStackRequest<java.util.List<Object>> { - - private String containerName; - - private Map<String, String> filters; - - public List(String containerName, Map<String, String> filters) { - this.containerName = containerName; - this.filters = filters; - //returnType(new TypeToken<List<Object>>(){}); -// target = target.path(containerName); -// for(String filter : new String[]{"prefix","delimiter","path","marker"}) { -// if(filters.get(filter) != null) { -// target = target.queryParam(filter, filters.get(filter)); -// } -// } -// return target.request(MediaType.APPLICATION_JSON).get(new GenericType<List<Object>>(){}); - } - - } - - public class CreateDirectory extends OpenStackRequest<Void> { - - private String container; - - private String path; - - public CreateDirectory(String container, String path) { - this.container = container; - this.path = path; -// endpoint.path(container).path(path).request().put(Entity.entity(new byte[1],"application/directory")); - } - - } - - public class Show extends OpenStackRequest<Object> { - - private String containerName; - - private String objectName; - - public Show(String containerName, String objectName) { - this.containerName = containerName; - this.objectName = objectName; -// return target.path(containerName).path(objectName).request(MediaType.APPLICATION_JSON).head(); - } - - } - - public class Upload extends OpenStackRequest<OpenStackResponse> { - - private ObjectForUpload objectForUpload; - - public Upload(ObjectForUpload objectForUpload) { - this.objectForUpload = objectForUpload; -// Invocation.Builder invocationBuilder = target.path(objectForUpload.getContainer()).path(objectForUpload.getName()).request(MediaType.APPLICATION_JSON); -// for(String key : objectForUpload.getProperties().keySet()) { -// invocationBuilder.header("x-object-meta-" + key, objectForUpload.getProperties().get(key)); -// } -// return invocationBuilder.put(Entity.entity(objectForUpload.getInputStream(), MediaType.APPLICATION_OCTET_STREAM), Response.class); - } - - } - - public class Download extends OpenStackRequest<ObjectDownload> { - - private String containerName; - - private String objectName; - - public Download(String containerName, String objectName) { - this.containerName = containerName; - this.objectName = objectName; -// Response response = target.path(containerName).path(objectName).request(MediaType.APPLICATION_JSON).get(); -// ObjectDownload objectDownload = new ObjectDownload(); -// objectDownload.setInputStream((InputStream) response.getEntity()); -// return objectDownload; - } - - } - - - public class Delete extends OpenStackRequest<Void> { - - private String containerName; - - private String objectName; - - public Delete(String containerName, String objectName) { - this.containerName = containerName; - this.objectName = objectName; - //return target.path(containerName).path(objectName).request(MediaType.APPLICATION_JSON).delete(); - } - - } + + private final OpenStackClient CLIENT; + + private String container; + + public ContainerResource(OpenStackClient client, String container) { + CLIENT = client; + this.container = container; + } + + public List list() { + return new List(container, null); + } + + public CreateDirectory createDirectory(String path) { + return new CreateDirectory(container, path); + } + + public Show show(String path) { + return new Show(container, path); + } + + public Upload upload(ObjectForUpload objectForUpload) { + return new Upload(objectForUpload); + } + + public Download download(String path) { + return new Download(container, path); + } + + public Delete delete(String path) { + return new Delete(container, path); + } + + public class List extends OpenStackRequest<java.util.List<Object>> { + + private String containerName; + + private Map<String, String> filters; + + public List(String containerName, Map<String, String> filters) { + this.containerName = containerName; + this.filters = filters; + //returnType(new TypeToken<List<Object>>(){}); +// target = target.path(containerName); +// for(String filter : new String[]{"prefix","delimiter","path","marker"}) { +// if(filters.get(filter) != null) { +// target = target.queryParam(filter, filters.get(filter)); +// } +// } +// return target.request(MediaType.APPLICATION_JSON).get(new GenericType<List<Object>>(){}); + } + + } + + public class CreateDirectory extends OpenStackRequest<Void> { + + private String container; + + private String path; + + public CreateDirectory(String container, String path) { + this.container = container; + this.path = path; +// endpoint.path(container).path(path).request().put(Entity.entity(new byte[1],"application/directory")); + } + + } + + public class Show extends OpenStackRequest<Object> { + + private String containerName; + + private String objectName; + + public Show(String containerName, String objectName) { + this.containerName = containerName; + this.objectName = objectName; +// return target.path(containerName).path(objectName).request(MediaType.APPLICATION_JSON).head(); + } + + } + + public class Upload extends OpenStackRequest<OpenStackResponse> { + + private ObjectForUpload objectForUpload; + + public Upload(ObjectForUpload objectForUpload) { + this.objectForUpload = objectForUpload; +// Invocation.Builder invocationBuilder = target.path(objectForUpload.getContainer()).path(objectForUpload.getName()).request(MediaType.APPLICATION_JSON); +// for(String key : objectForUpload.getProperties().keySet()) { +// invocationBuilder.header("x-object-meta-" + key, objectForUpload.getProperties().get(key)); +// } +// return invocationBuilder.put(Entity.entity(objectForUpload.getInputStream(), MediaType.APPLICATION_OCTET_STREAM), Response.class); + } + + } + + public class Download extends OpenStackRequest<ObjectDownload> { + + private String containerName; + + private String objectName; + + public Download(String containerName, String objectName) { + this.containerName = containerName; + this.objectName = objectName; +// Response response = target.path(containerName).path(objectName).request(MediaType.APPLICATION_JSON).get(); +// ObjectDownload objectDownload = new ObjectDownload(); +// objectDownload.setInputStream((InputStream) response.getEntity()); +// return objectDownload; + } + + } + + + public class Delete extends OpenStackRequest<Void> { + + private String containerName; + + private String objectName; + + public Delete(String containerName, String objectName) { + this.containerName = containerName; + this.objectName = objectName; + //return target.path(containerName).path(objectName).request(MediaType.APPLICATION_JSON).delete(); + } + + } } diff --git a/swift-client/src/main/java/com/woorea/openstack/swift/api/ContainersResource.java b/swift-client/src/main/java/com/woorea/openstack/swift/api/ContainersResource.java index 77dbc8a..663152c 100644 --- a/swift-client/src/main/java/com/woorea/openstack/swift/api/ContainersResource.java +++ b/swift-client/src/main/java/com/woorea/openstack/swift/api/ContainersResource.java @@ -22,69 +22,69 @@ import com.woorea.openstack.base.client.OpenStackRequest; import com.woorea.openstack.swift.model.Container; public class ContainersResource { - - private final OpenStackClient CLIENT; - - public ContainersResource(OpenStackClient client) { - CLIENT = client; - } - - public List list() { - return new List(); - } - - public Create create(String name) { - return new Create(name); - } - - public Show show(String name) { - return new Show(name); - } - - public Delete delete(String name) { - return new Delete(name); - } - - public ContainerResource container(String name) { - return new ContainerResource(CLIENT, name); - } - - public class List extends OpenStackRequest<java.util.List<Container>> { + + private final OpenStackClient CLIENT; + + public ContainersResource(OpenStackClient client) { + CLIENT = client; + } + + public List list() { + return new List(); + } + + public Create create(String name) { + return new Create(name); + } + + public Show show(String name) { + return new Show(name); + } + + public Delete delete(String name) { + return new Delete(name); + } + + public ContainerResource container(String name) { + return new ContainerResource(CLIENT, name); + } + + public class List extends OpenStackRequest<java.util.List<Container>> { - public List() { - //return target.request(MediaType.APPLICATION_JSON).get(new GenericType<List<Container>>(){}); - } + public List() { + //return target.request(MediaType.APPLICATION_JSON).get(new GenericType<List<Container>>(){}); + } - } + } - public class Create extends OpenStackRequest<Container> { - - public Create(String containerName) { - //return target.path(containerName).request().method("PUT",Entity.text("*")); - } + public class Create extends OpenStackRequest<Container> { + + public Create(String containerName) { + //return target.path(containerName).request().method("PUT",Entity.text("*")); + } - } - - public class Show extends OpenStackRequest<Container> { + } + + public class Show extends OpenStackRequest<Container> { - private String containerName; - - public Show(String containerName) { -// return target.path(containerName).request(MediaType.APPLICATION_JSON).head(); - } + private String containerName; + + public Show(String containerName) { +// return target.path(containerName).request(MediaType.APPLICATION_JSON).head(); + } - } - - public class Delete extends OpenStackRequest<Void> { + } + + public class Delete extends OpenStackRequest<Void> { - private String containerName; - - public Delete(String containerName) { - this.containerName = containerName; - //return target.path(containerName).request(MediaType.APPLICATION_JSON).delete(); - } + private String containerName; + + public Delete(String containerName) { + this.containerName = containerName; + //return target.path(containerName).request(MediaType.APPLICATION_JSON).delete(); + } - } - + } + } |