Class Document


  • public abstract class Document
    extends PoolElement
    This class represents an OpenNebula document. 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, see DocumentPool
    For example:
     
     public class GenericObjA extends Document
     {
         private static final int TYPE = 200;
    
         public GenericObjA(int id, Client client)
         {
             super(id, client);
         }
    
         public GenericObjA(Node xmlElement, Client client)
         {
             super(xmlElement, client);
         }
    
         public static OneResponse allocate(Client client, String description)
         {
             return Document.allocate(client, description, TYPE);
         }
     }
     
     
    • Constructor Detail

      • Document

        public Document​(int id,
                        Client client)
        Creates a new Document representation.
        Parameters:
        id - The document id.
        client - XML-RPC Client.
      • Document

        public Document​(org.w3c.dom.Node xmlElement,
                        Client client)
        See Also:
        PoolElement
    • Method Detail

      • lock

        public static OneResponse lock​(Client client,
                                       int id,
                                       int level)
        lock this Document
        Parameters:
        client - XML-RPC Client.
        id - The Image id.
        level - Lock level.
        Returns:
        If an error occurs the error message contains the reason.
      • unlock

        public static OneResponse unlock​(Client client,
                                         int id)
        Unlock this Document
        Parameters:
        client - XML-RPC Client.
        id - The Image id.
        Returns:
        If an error occurs the error message contains the reason.
      • allocate

        protected static OneResponse allocate​(Client client,
                                              java.lang.String description,
                                              int type)
        Allocates a new Document in OpenNebula.
        Parameters:
        client - XML-RPC Client.
        description - A string containing the template of the document.
        Returns:
        If successful the message contains the associated id generated for this Document.
      • info

        public OneResponse info()
        Retrieves the information of the given Document.
        Returns:
        If successful the message contains the string with the information returned by OpenNebula.
      • delete

        public OneResponse delete()
        Deletes a document from OpenNebula.
        Returns:
        A encapsulated response.
      • update

        public OneResponse update​(java.lang.String new_document)
        Replaces the document template contents.
        Parameters:
        new_document - New template contents.
        Returns:
        If successful the message contains the document id.
      • update

        public OneResponse update​(java.lang.String new_document,
                                  boolean append)
        Replaces the document template contents.
        Parameters:
        new_document - New template contents.
        append - True to append new attributes instead of replace the whole template
        Returns:
        If successful the message contains the document id.
      • publish

        public OneResponse publish​(boolean publish)
        Publishes or unpublishes a document.
        Parameters:
        publish - True for publishing, false for unpublishing.
        Returns:
        If successful the message contains the document id.
      • chown

        public OneResponse chown​(int uid,
                                 int gid)
        Changes the owner/group
        Parameters:
        uid - The new owner user ID. Set it to -1 to leave the current one.
        gid - The new group ID. Set it to -1 to leave the current one.
        Returns:
        If an error occurs the error message contains the reason.
      • chmod

        public OneResponse chmod​(int owner_u,
                                 int owner_m,
                                 int owner_a,
                                 int group_u,
                                 int group_m,
                                 int group_a,
                                 int other_u,
                                 int other_m,
                                 int other_a)
        Changes the document permissions
        Parameters:
        owner_u - 1 to allow, 0 deny, -1 do not change
        owner_m - 1 to allow, 0 deny, -1 do not change
        owner_a - 1 to allow, 0 deny, -1 do not change
        group_u - 1 to allow, 0 deny, -1 do not change
        group_m - 1 to allow, 0 deny, -1 do not change
        group_a - 1 to allow, 0 deny, -1 do not change
        other_u - 1 to allow, 0 deny, -1 do not change
        other_m - 1 to allow, 0 deny, -1 do not change
        other_a - 1 to allow, 0 deny, -1 do not change
        Returns:
        If an error occurs the error message contains the reason.
      • chmod

        public OneResponse chmod​(java.lang.String octet)
        Changes the permissions
        Parameters:
        octet - Permissions octed , e.g. 640
        Returns:
        If an error occurs the error message contains the reason.
      • chmod

        public OneResponse chmod​(int octet)
        Changes the permissions
        Parameters:
        octet - Permissions octed , e.g. 640
        Returns:
        If an error occurs the error message contains the reason.
      • clone

        public OneResponse clone​(java.lang.String name)
        Clones this document into a new one
        Parameters:
        name - Name for the new document.
        Returns:
        If successful the message contains the new document ID.
      • rename

        public OneResponse rename​(java.lang.String name)
        Renames this document
        Parameters:
        name - New name for the document.
        Returns:
        If an error occurs the error message contains the reason.
      • lock

        public OneResponse lock​(int level)
        Locks this object
        Parameters:
        level - int to identify the lock level
        Returns:
        In case of success, a boolean with true if the lock was granted, and false if the object is already locked.
      • unlock

        public OneResponse unlock()
        Unlocks this object
        Returns:
        If an error occurs the error message contains the reason.
      • publish

        public OneResponse publish()
        Publishes the document.
        Returns:
        If successful the message contains the document id.
      • unpublish

        public OneResponse unpublish()
        Unpublishes the document.
        Returns:
        If successful the message contains the document id.
      • chown

        public OneResponse chown​(int uid)
        Changes the owner
        Parameters:
        uid - The new owner user ID.
        Returns:
        If an error occurs the error message contains the reason.
      • chgrp

        public OneResponse chgrp​(int gid)
        Changes the group
        Parameters:
        gid - The new group ID.
        Returns:
        If an error occurs the error message contains the reason.