From 77a48e21e84a158cab36aee2b9d3f1c622057aa0 Mon Sep 17 00:00:00 2001 From: seshukm Date: Wed, 25 Jul 2018 20:02:19 +0800 Subject: basic code refactoring of swift-client module Issue-ID: SO-729 Change-Id: I33ae9f89327458394fbc33952d125dca303d0bf3 Signed-off-by: seshukm --- .../java/com/woorea/openstack/swift/Swift.java | 44 ++-- .../openstack/swift/api/AccountResource.java | 22 +- .../openstack/swift/api/ContainerResource.java | 258 ++++++++++----------- .../openstack/swift/api/ContainersResource.java | 112 ++++----- 4 files changed, 218 insertions(+), 218 deletions(-) (limited to 'swift-client') 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 { + public class ShowAccount extends OpenStackRequest { - 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> { - - private String containerName; - - private Map filters; - - public List(String containerName, Map filters) { - this.containerName = containerName; - this.filters = filters; - //returnType(new TypeToken>(){}); -// 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>(){}); - } - - } - - public class CreateDirectory extends OpenStackRequest { - - 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 { - - 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 { - - 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 { - - 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 { - - 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> { + + private String containerName; + + private Map filters; + + public List(String containerName, Map filters) { + this.containerName = containerName; + this.filters = filters; + //returnType(new TypeToken>(){}); +// 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>(){}); + } + + } + + public class CreateDirectory extends OpenStackRequest { + + 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 { + + 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 { + + 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 { + + 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 { + + 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> { + + 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> { - public List() { - //return target.request(MediaType.APPLICATION_JSON).get(new GenericType>(){}); - } + public List() { + //return target.request(MediaType.APPLICATION_JSON).get(new GenericType>(){}); + } - } + } - public class Create extends OpenStackRequest { - - public Create(String containerName) { - //return target.path(containerName).request().method("PUT",Entity.text("*")); - } + public class Create extends OpenStackRequest { + + public Create(String containerName) { + //return target.path(containerName).request().method("PUT",Entity.text("*")); + } - } - - public class Show extends OpenStackRequest { + } + + public class Show extends OpenStackRequest { - 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 { + } + + public class Delete extends OpenStackRequest { - 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(); + } - } - + } + } -- cgit 1.2.3-korg