org.javaswift.joss.client.core
Class AbstractContainer

java.lang.Object
  extended by org.javaswift.joss.client.core.AbstractObjectStoreEntity<ContainerInformation>
      extended by org.javaswift.joss.client.core.AbstractContainer
All Implemented Interfaces:
Comparable<Container>, Container, ListHolder<StoredObject>, ListSubject, ObjectStoreEntity
Direct Known Subclasses:
AbstractWebsite, ContainerImpl, ContainerMock

public abstract class AbstractContainer
extends AbstractObjectStoreEntity<ContainerInformation>
implements Container


Field Summary
static org.slf4j.Logger LOG
           
protected  String name
           
 
Fields inherited from class org.javaswift.joss.client.core.AbstractObjectStoreEntity
ALLOW_CACHING, info, staleHeaders
 
Constructor Summary
AbstractContainer(Account account, String name, boolean allowCaching)
           
 
Method Summary
 int compareTo(Container o)
           
 Container create()
          Creates a Container in the Account.
protected  Metadata createMetadataEntry(String name, String value)
           
 void delete()
          Deletes a Container from the Account.
 boolean equals(Object o)
           
 Account getAccount()
           
 long getBytesUsed()
          The number of bytes stored by the StoredObjects in the Container.
 String getContainerReadPermission()
           
 String getcontainerWritePermission()
           
 int getCount()
          The number of StoredObjects in the Container.
 ContainerCommandFactory getFactory()
           
 FormPost getFormPost(String redirect, long maxFileSize, long maxFileCount, long seconds)
          Returns a signature that can be used to upload files directly from the browser, using a basic form element.
protected  void getInfo(boolean allowErrorLog)
           
 int getMaxPageSize()
          The ObjectStore server will force a maximum page size.
 String getName()
           
 StoredObject getObjectSegment(String name, int part)
          Returns an object that represents a segment of a single large object
 PaginationMap getPaginationMap(int pageSize)
          Returns a PaginationMap of a listing of Containers.
 PaginationMap getPaginationMap(String prefix, int pageSize)
          Returns a PaginationMap of a listing of Containers.
 String getPathForEntity()
           
 int hashCode()
           
 boolean isPublic()
           
 Collection<StoredObject> list()
          Returns all the containers in an Account.
 Collection<StoredObject> list(PaginationMap paginationMap, int page)
          Returns a number equal to pageSize of Container elements, starting with the first element after the Container named the same as marker.
 Collection<StoredObject> list(String prefix, String marker, int pageSize)
          Returns a number equal to pageSize of Container elements, starting with the first element after the Container named the same as marker.
 void makePrivate()
          Takes a single Container and makes it private.
 void makePublic()
          Takes a single Container and makes it public.
 void metadataSetFromHeaders()
          Declares to the ListSubject that a number of fields have been read from the list operation and therefore do not have to be fetched individually, unless caching is turned off.
protected  void saveSpecificMetadata()
           
 void setBytesUsed(long bytesUsed)
           
 void setContainerRights(boolean publicContainer)
           
 void setContainerRights(String writePermissions, String readPermissions)
           
 void setCount(int count)
           
 void uploadSegmentedObjects(String name, UploadInstructions uploadInstructions)
           
 
Methods inherited from class org.javaswift.joss.client.core.AbstractObjectStoreEntity
checkForInfo, checkForInfo, checkForInfoAndAllowHeaderSet, checkForInfoDisallowErrorLog, exists, getMetadata, getMetadata, getPath, invalidate, isAllowCaching, isInfoRetrieved, isStale, reload, removeAndDoNotSaveMetadata, removeAndSaveMetadata, saveMetadata, setAndDoNotSaveMetadata, setAndSaveMetadata, setInfoRetrieved, setMetadata
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.javaswift.joss.model.Container
exists, getObject, isInfoRetrieved, reload
 
Methods inherited from interface org.javaswift.joss.model.ObjectStoreEntity
getMetadata, getMetadata, getPath, removeAndDoNotSaveMetadata, removeAndSaveMetadata, saveMetadata, setAndDoNotSaveMetadata, setAndSaveMetadata, setMetadata
 

Field Detail

LOG

public static final org.slf4j.Logger LOG

name

protected final String name
Constructor Detail

AbstractContainer

public AbstractContainer(Account account,
                         String name,
                         boolean allowCaching)
Method Detail

list

public Collection<StoredObject> list()
Description copied from interface: ListHolder
Returns all the containers in an Account. Note that this method returns a maxmimum of 9,999 Containers and no more (see http://docs.openstack.org/api/openstack-object-storage/1.0/content/list-objects.html)

Specified by:
list in interface ListHolder<StoredObject>
Returns:
the containers in an Account

list

public Collection<StoredObject> list(PaginationMap paginationMap,
                                     int page)
Description copied from interface: ListHolder
Returns a number equal to pageSize of Container elements, starting with the first element after the Container named the same as marker.

Specified by:
list in interface ListHolder<StoredObject>
Parameters:
paginationMap - the map that is fetched with getPaginationMap and maps from page to marker
page - the page to return the Containers for
Returns:
page of Containers in an Account with a total of pageSize elements

list

public Collection<StoredObject> list(String prefix,
                                     String marker,
                                     int pageSize)
Description copied from interface: ListHolder
Returns a number equal to pageSize of Container elements, starting with the first element after the Container named the same as marker.

Specified by:
list in interface ListHolder<StoredObject>
marker - the last element on the previous page
pageSize - the number of elements to return
Returns:
page of Containers in an Account with a total of pageSize elements

metadataSetFromHeaders

public void metadataSetFromHeaders()
Description copied from interface: ListSubject
Declares to the ListSubject that a number of fields have been read from the list operation and therefore do not have to be fetched individually, unless caching is turned off.

Specified by:
metadataSetFromHeaders in interface ListSubject

getPaginationMap

public PaginationMap getPaginationMap(String prefix,
                                      int pageSize)
Description copied from interface: ListHolder
Returns a PaginationMap of a listing of Containers. The map can be used to supply the OpenStack API with a marker (ie, last record on the previous page) and a limit (ie, page size). BE AWARE: this method iterates over ALL Container names to draw up the map, therefore it must be considered an expensive call.

Specified by:
getPaginationMap in interface ListHolder<StoredObject>
Parameters:
prefix - the names must start with the prefix or else will be filtered out
pageSize - number of elements on a single page
Returns:
the pagination map for all the Container elements in Account

getPaginationMap

public PaginationMap getPaginationMap(int pageSize)
Description copied from interface: ListHolder
Returns a PaginationMap of a listing of Containers. The map can be used to supply the OpenStack API with a marker (ie, last record on the previous page) and a limit (ie, page size). BE AWARE: this method iterates over ALL Container names to draw up the map, therefore it must be considered an expensive call.

Specified by:
getPaginationMap in interface ListHolder<StoredObject>
Parameters:
pageSize - number of elements on a single page
Returns:
the pagination map for all the Container elements in Account

getObjectSegment

public StoredObject getObjectSegment(String name,
                                     int part)
Description copied from interface: Container
Returns an object that represents a segment of a single large object

Specified by:
getObjectSegment in interface Container
Parameters:
name - the name of the object to create a handle for
part - the part of the large object that the segment represents
Returns:
the object handle

getCount

public int getCount()
Description copied from interface: Container
The number of StoredObjects in the Container. If the Container was read by Account.list, this value will not be refetched from the server, unless caching is disabled.

Specified by:
getCount in interface Container
Specified by:
getCount in interface ListHolder<StoredObject>
Returns:
number of StoredObjects

getBytesUsed

public long getBytesUsed()
Description copied from interface: Container
The number of bytes stored by the StoredObjects in the Container. If the Container was read by Account.list, this value will not be refetched from the server, unless caching is disabled.

Specified by:
getBytesUsed in interface Container
Returns:
number of bytes

getFormPost

public FormPost getFormPost(String redirect,
                            long maxFileSize,
                            long maxFileCount,
                            long seconds)
Description copied from interface: Container
Returns a signature that can be used to upload files directly from the browser, using a basic form element.

Specified by:
getFormPost in interface Container
Parameters:
redirect - redirection URL after the upload has succeeded
maxFileSize - max number of bytes allowed to upload
maxFileCount - max number of files allowed to upload
seconds - number of seconds for the temporary URL to be valid
Returns:
FormPost signature for uploading an object directly from the browser

setCount

public void setCount(int count)
Specified by:
setCount in interface Container

setBytesUsed

public void setBytesUsed(long bytesUsed)
Specified by:
setBytesUsed in interface Container

isPublic

public boolean isPublic()
Specified by:
isPublic in interface Container

getContainerReadPermission

public String getContainerReadPermission()
Specified by:
getContainerReadPermission in interface Container

getcontainerWritePermission

public String getcontainerWritePermission()
Specified by:
getcontainerWritePermission in interface Container

getName

public String getName()
Specified by:
getName in interface ListSubject

getAccount

public Account getAccount()
Specified by:
getAccount in interface Container

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

compareTo

public int compareTo(Container o)
Specified by:
compareTo in interface Comparable<Container>

createMetadataEntry

protected Metadata createMetadataEntry(String name,
                                       String value)
Specified by:
createMetadataEntry in class AbstractObjectStoreEntity<ContainerInformation>

uploadSegmentedObjects

public void uploadSegmentedObjects(String name,
                                   UploadInstructions uploadInstructions)

getMaxPageSize

public int getMaxPageSize()
Description copied from interface: ListHolder
The ObjectStore server will force a maximum page size. This value helps to determine blocks that must be read, which is used internally for setting up a pagination map.

Specified by:
getMaxPageSize in interface ListHolder<StoredObject>
Returns:
maximum page size for the child entity

getFactory

public ContainerCommandFactory getFactory()

makePublic

public void makePublic()
Description copied from interface: Container
Takes a single Container and makes it public. ALL (!) the objects in the Container are now public, so be very careful exercising this option. The public URL can now be used to access objects.

Specified by:
makePublic in interface Container

makePrivate

public void makePrivate()
Description copied from interface: Container
Takes a single Container and makes it private. All the objects in the Container are now private and can no longer be accessed through the public URL.

Specified by:
makePrivate in interface Container

setContainerRights

public void setContainerRights(boolean publicContainer)

setContainerRights

public void setContainerRights(String writePermissions,
                               String readPermissions)
Specified by:
setContainerRights in interface Container

create

public Container create()
Description copied from interface: Container
Creates a Container in the Account.

Specified by:
create in interface Container

delete

public void delete()
Description copied from interface: Container
Deletes a Container from the Account. Note that the Container must be empty in order to be deleted.

Specified by:
delete in interface Container

saveSpecificMetadata

protected void saveSpecificMetadata()
Specified by:
saveSpecificMetadata in class AbstractObjectStoreEntity<ContainerInformation>

getInfo

protected void getInfo(boolean allowErrorLog)
Specified by:
getInfo in class AbstractObjectStoreEntity<ContainerInformation>

getPathForEntity

public String getPathForEntity()
                        throws UnsupportedEncodingException
Specified by:
getPathForEntity in class AbstractObjectStoreEntity<ContainerInformation>
Throws:
UnsupportedEncodingException


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