
nl.tweeenveertig.openstack.client.impl.AccountImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of joss Show documentation
Show all versions of joss Show documentation
Java Client library for OpenStack Storage (Swift)
package nl.tweeenveertig.openstack.client.impl;
import nl.tweeenveertig.openstack.command.identity.access.AccessImpl;
import nl.tweeenveertig.openstack.model.Container;
import nl.tweeenveertig.openstack.client.core.AbstractAccount;
import nl.tweeenveertig.openstack.command.account.AccountInformationCommand;
import nl.tweeenveertig.openstack.command.account.AccountMetadataCommand;
import nl.tweeenveertig.openstack.command.account.ListContainersCommand;
import nl.tweeenveertig.openstack.command.identity.AuthenticationCommand;
import org.apache.http.client.HttpClient;
import java.util.ArrayList;
import java.util.Collection;
public class AccountImpl extends AbstractAccount {
private AuthenticationCommand command;
private HttpClient httpClient;
private AccessImpl access;
public AccessImpl authenticate() {
return access = command.call();
}
public AccountImpl(AuthenticationCommand command, HttpClient httpClient, AccessImpl access, boolean allowCaching) {
super(allowCaching);
this.command = command;
this.httpClient = httpClient;
this.access = access;
}
public Collection listContainers() {
Collection containerNames = new ListContainersCommand(this, httpClient, access).call();
Collection containers = new ArrayList();
for (String containerName : containerNames) {
containers.add(this.getContainer(containerName));
}
return containers;
}
public Container getContainer(String containerName) {
return new ContainerImpl(this, containerName, isAllowCaching());
}
@Override
protected void saveMetadata() {
new AccountMetadataCommand(this, getClient(), getAccess(), info.getMetadata()).call();
}
protected void getInfo() {
this.info = new AccountInformationCommand(this, httpClient, access).call();
this.setInfoRetrieved();
}
public HttpClient getClient() {
return httpClient;
}
public AccessImpl getAccess() {
return access;
}
public String getPublicURL() {
return access.getPublicURL();
}
}