DocumentPool (OpenNebula Cloud API)
Description: declaration: package: org.opennebula.client.document, class: DocumentPool

Package org.opennebula.client.document

# Class DocumentPool

java.lang.Object
org.opennebula.client.Pool
org.opennebula.client.document.DocumentPool

public abstract class DocumentPool extends Pool

This class represents an OpenNebula Document pool.

Documents are generic objects. You can dynamically create new Pools in OpenNebula, creating subclasses with different TYPE values.
TYPE must be the same for the corresponding pool element, see `Document`
For example:

     public class GenericObjAPool extends DocumentPool implements Iterable<GenericObjA>
     {
         private static final int TYPE = 200;

         protected int type()
         {
             return TYPE;
         }

         public GenericObjAPool(Client client)
         {
             super(client);
         }

         public GenericObjAPool(Client client, int filter)
         {
             super(client, filter);
         }

         public GenericObjA factory(Node node)
         {
             return new GenericObjA(node, client);
         }

         public Iterator<GenericObjA> iterator()
         {
             AbstractList<GenericObjA> ab = new AbstractList<GenericObjA>()
             {
                 public int size()
                 {
                     return getLength();
                 }

                 public GenericObjA get(int index)
                 {
                     return (GenericObjA) item(index);
                 }
             };

             return ab.iterator();
         }
     }

- ## Field Summary

  ### Fields inherited from class org.opennebula.client.Pool

  `ALL, client, elementName, GROUP, infoMethod, MINE, MINE_GROUP, poolElements, xpath`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DocumentPool(Client client)`
  Creates a new Document pool with the default filter flag value set to `Pool.MINE_GROUP` (Document belonging to the connected user, and the ones in his group)
  `DocumentPool(Client client, int filter)`
  Creates a new Document pool.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Document`
  `getById(int id)`
  Returns the Document with the given Id from the pool.
  `OneResponse`
  `info()`
  Loads the xml representation of all or part of the Documents in the pool.
  `OneResponse`
  `info(int filter, int startId, int endId)`
  Retrieves all or part of the Documents in the pool.
  `OneResponse`
  `infoAll()`
  Loads the xml representation of all the Documents in the pool.
  `OneResponse`
  `infoGroup()`
  Loads the xml representation of all the connected user's Documents and the ones in his group.
  `OneResponse`
  `infoMine()`
  Loads the xml representation of all the connected user's Documents.
  `protected abstract int`
  `type()`

  ### Methods inherited from class org.opennebula.client.Pool

  `factory, getLength, info, info, infoAll, infoGroup, infoGroupPrimary, infoMine, item, processInfo, xmlrpcInfo`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### DocumentPool

    public DocumentPool(Client client)
    Creates a new Document pool with the default filter flag value set to `Pool.MINE_GROUP` (Document belonging to the connected user, and the ones in his group)
    Parameters:
      `client` - XML-RPC Client.
    See Also:
      - `DocumentPool(Client, int)`

  - ### DocumentPool

    public DocumentPool(Client client, int filter)
    Creates a new Document pool.
    Parameters:
      `client` - XML-RPC Client.
      `filter` - Filter flag to use by default in the method `info()`. Possible values:
      - `Pool.ALL`: All Documents
      - `Pool.MINE`: Connected user's Documents
      - `Pool.MINE_GROUP`: Connected user's Documents, and the ones in his group
      - `Pool.GROUP`: User's primary group Documents
      - >= 0 UID User's Documents

- ## Method Details

  - ### type

    protected abstract int type()

  - ### info

    public OneResponse info()
    Loads the xml representation of all or part of the Documents in the pool. The filter used is the one set in the constructor.
    Overrides:
      `info` in class `Pool`
    Returns:
      If successful the message contains the string with the information returned by OpenNebula.
    See Also:
      - `info()`

  - ### infoAll

    public OneResponse infoAll()
    Loads the xml representation of all the Documents in the pool.
    Overrides:
      `infoAll` in class `Pool`
    Returns:
      If successful the message contains the string with the information returned by OpenNebula.

  - ### infoMine

    public OneResponse infoMine()
    Loads the xml representation of all the connected user's Documents.
    Overrides:
      `infoMine` in class `Pool`
    Returns:
      If successful the message contains the string with the information returned by OpenNebula.

  - ### infoGroup

    public OneResponse infoGroup()
    Loads the xml representation of all the connected user's Documents and the ones in his group.
    Overrides:
      `infoGroup` in class `Pool`
    Returns:
      If successful the message contains the string with the information returned by OpenNebula.

  - ### info

    public OneResponse info(int filter, int startId, int endId)
    Retrieves all or part of the Documents in the pool. The Documents to retrieve can be also filtered by Id, specifying the first and last Id to include.
    Overrides:
      `info` in class `Pool`
    Parameters:
      `filter` - Filter flag to use. Possible values:
      - `Pool.ALL`: All Documents
      - `Pool.MINE`: Connected user's Documents
      - `Pool.MINE_GROUP`: Connected user's Documents, and the ones in his group
      - `Pool.GROUP`: User's primary group Documents
      - >= 0 UID User's Documents
      `startId` - Lowest Id to retrieve
      `endId` - Biggest Id to retrieve
    Returns:
      If successful the message contains the string with the information returned by OpenNebula.

  - ### getById

    public Document getById(int id)
    Returns the Document with the given Id from the pool. If it is not found, then returns null. The method `info()` must be called before.
    Overrides:
      `getById` in class `Pool`
    Parameters:
      `id` - of the ACl rule to retrieve
    Returns:
      The Document with the given Id, or null if it was not found.