org.javaswift.joss.model
Interface Account

All Superinterfaces:
ListHolder<Container>, ObjectStoreEntity
All Known Implementing Classes:
AbstractAccount, AccountImpl, AccountMock

public interface Account
extends ObjectStoreEntity, ListHolder<Container>

Account is the root entity in Object Store. It allows you access to the various containers underneath. Note that you need to call getContainer to work on Containers. The method returns a stub for dealing with Containers, but does not create a container in the Object Store. The creation only takes place when you run the create method on a Container. Information on the container will not be retrieved until the time you actually call on that information - ie, information is lazily loaded.

Author:
Robert Bor

Method Summary
 Access authenticate()
          Trigger the authentication against Object Store.
 long getActualServerTimeInSeconds(long seconds)
          Calculate the server time taking into account the number of seconds passed.
 long getBytesUsed()
          The number of bytes stored by the StoredObjects in all Containers in the Account.
 Container getContainer(String name)
          Returns a handle for a container.
 String getHashPassword()
          Returns the hash password originally set on Account.
 int getNumberOfCalls()
          Returns the number of HTTP calls that have been made to the ObjectStore server.
 int getObjectCount()
          The number of StoredObjects in all Containers in the Account.
 String getOriginalHost()
          Returns the original host, regardless of the configured public and private host settings
 String getPrivateURL()
          Returns the private URL which is used for the underlying stored objects
 String getPublicURL()
          Returns the public URL which is used for the underlying stored objects
 long getServerTime()
          Returns the server time in milliseconds since 1970
 Tenants getTenants()
          Returns the tenants of the account.
 Website getWebsite(String name)
          Returns a handle for a website.
 void increaseCallCounter()
          Increase the call counter which tracks how many calls are made to the ObjectStore
 boolean isAllowReauthenticate()
          Whether reauthentication on expiration of the authentication token is allowed, or this is done manually by the client
 boolean isTenantSupplied()
          Checks whether a tenant ID and/or name were supplied.
 void reload()
          Force the Account to reload its metadata
 void resetContainerCache()
          Empties the Container Cache
 Account setAllowContainerCaching(boolean containerCaching)
          If ContainerCaching is enabled, Account will keep track of its Container instances and reuse them.
 Account setAllowReauthenticate(boolean allowReauthenticate)
          An ObjectStore authentication token will expire after 24 hours.
 Account setHashPassword(String hashPassword)
          Saves the password to the Account.
 Account setPrivateHost(String host)
          Set your own private host to prefix the public URLs of objects
 Account setPublicHost(String host)
          Set your own public host to prefix the public URLs of objects
 void synchronizeWithServerTime()
          Compares the local time to the server time and maintains a number of milliseconds to account for the difference.
 
Methods inherited from interface org.javaswift.joss.model.ObjectStoreEntity
getMetadata, getMetadata, getPath, removeAndDoNotSaveMetadata, removeAndSaveMetadata, saveMetadata, setAndDoNotSaveMetadata, setAndSaveMetadata, setMetadata
 
Methods inherited from interface org.javaswift.joss.model.ListHolder
getCount, getMaxPageSize, getPaginationMap, getPaginationMap, list, list, list
 

Method Detail

getContainer

Container getContainer(String name)
Returns a handle for a container. Note that this method DOES NOT create a container in the Object Store or otherwise place a call to the Object Store

Parameters:
name - name of the container to create a handle for
Returns:
the container handle

getWebsite

Website getWebsite(String name)
Returns a handle for a website. Note that this method DOES NOT create a website in the Object Store or otherwise place a call to the Object Store

Parameters:
name - name of the website to create a handle for
Returns:
the website handle

authenticate

Access authenticate()
Trigger the authentication against Object Store. There are two use cases for this method. The first is triggered pro-actively by the user by calling authenticate on the client. The second is when the token has expired and AbstractSecureCommand triggers a re-authentication.

Returns:
the access element including a new token

getPublicURL

String getPublicURL()
Returns the public URL which is used for the underlying stored objects

Returns:
the public URL of the underlying stored objects

getPrivateURL

String getPrivateURL()
Returns the private URL which is used for the underlying stored objects

Returns:
the private URL of the underlying stored objects

reload

void reload()
Force the Account to reload its metadata


getBytesUsed

long getBytesUsed()
The number of bytes stored by the StoredObjects in all Containers in the Account.

Returns:
number of bytes

getObjectCount

int getObjectCount()
The number of StoredObjects in all Containers in the Account.

Returns:
number of StoredObjects

getServerTime

long getServerTime()
Returns the server time in milliseconds since 1970

Returns:
server time

synchronizeWithServerTime

void synchronizeWithServerTime()
Compares the local time to the server time and maintains a number of milliseconds to account for the difference. This number is taken into account when an absolute expiry time is passed to the server.


getActualServerTimeInSeconds

long getActualServerTimeInSeconds(long seconds)
Calculate the server time taking into account the number of seconds passed. This method makes use of the server time modifier which is calculated in synchronizeWithServerTime().

Parameters:
seconds - number of seconds after the actual server time
Returns:
calculated server time, including the number of seconds in the future

setAllowReauthenticate

Account setAllowReauthenticate(boolean allowReauthenticate)
An ObjectStore authentication token will expire after 24 hours. In a long-living web application, the account instance may exist longer than that. If reauthentication is allowed, a new token will be fetched once the existing one has expired.

Parameters:
allowReauthenticate - whether reauthentication is allowed
Returns:
instance of Account

setPublicHost

Account setPublicHost(String host)
Set your own public host to prefix the public URLs of objects

Parameters:
host - host of an object's public URL
Returns:
instance of Account

setPrivateHost

Account setPrivateHost(String host)
Set your own private host to prefix the public URLs of objects

Parameters:
host - host of an object's private URL
Returns:
instance of Account

setAllowContainerCaching

Account setAllowContainerCaching(boolean containerCaching)
If ContainerCaching is enabled, Account will keep track of its Container instances and reuse them.

Parameters:
containerCaching - whether container caching is allowed

setHashPassword

Account setHashPassword(String hashPassword)
Saves the password to the Account. The password will be used to create server side hashes. This is required for TempURL (both GET and PUT). The server will match a generated hash against the hash that is passed in a tempURL. If identical, it passed the first test. Note that if password is not set, TempURLs will not work. Note that the password saved is the one set either in AccountConfig, or set with Account.setHashPassword(String).

Parameters:
hashPassword - the password to use for generating the hashes

getHashPassword

String getHashPassword()
Returns the hash password originally set on Account.

Returns:
hash password

resetContainerCache

void resetContainerCache()
Empties the Container Cache


isAllowReauthenticate

boolean isAllowReauthenticate()
Whether reauthentication on expiration of the authentication token is allowed, or this is done manually by the client

Returns:
whether reauthentication is allowed

increaseCallCounter

void increaseCallCounter()
Increase the call counter which tracks how many calls are made to the ObjectStore


getNumberOfCalls

int getNumberOfCalls()
Returns the number of HTTP calls that have been made to the ObjectStore server. This could be useful to check the efficiency of the methods and configuration in use

Returns:
number of calls made to the ObjectStore server

getOriginalHost

String getOriginalHost()
Returns the original host, regardless of the configured public and private host settings

Returns:
original public host

getTenants

Tenants getTenants()
Returns the tenants of the account. Note that this is the only Account method that interacts with the object store and will work when no tenant has been set. All others will throw an exception.

Returns:
the tenants belonging to the Account

isTenantSupplied

boolean isTenantSupplied()
Checks whether a tenant ID and/or name were supplied. If not, the account can only be used to retrieve a list of tenants.



Copyright © 2012-2014 42 BV. All Rights Reserved.