OpenNebula
Cloud API

org.opennebula.client.document
Class Document

java.lang.Object
  extended by org.opennebula.client.PoolElement
      extended by org.opennebula.client.document.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);
     }
 }
 
 


Field Summary
 
Fields inherited from class org.opennebula.client.PoolElement
client, id, xml, xpath
 
Constructor Summary
Document(int id, Client client)
          Creates a new Document representation.
Document(org.w3c.dom.Node xmlElement, Client client)
           
 
Method Summary
protected static OneResponse allocate(Client client, java.lang.String description, int type)
          Allocates a new Document in OpenNebula.
 OneResponse chgrp(int gid)
          Changes the group
 OneResponse chmod(int octet)
          Changes the permissions
 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
 OneResponse chmod(java.lang.String octet)
          Changes the permissions
 OneResponse chown(int uid)
          Changes the owner
 OneResponse chown(int uid, int gid)
          Changes the owner/group
 OneResponse clone(java.lang.String name)
          Clones this document into a new one
 OneResponse delete()
          Deletes a document from OpenNebula.
 OneResponse info()
          Retrieves the information of the given Document.
 OneResponse publish()
          Publishes the document.
 OneResponse publish(boolean publish)
          Publishes or unpublishes a document.
 OneResponse unpublish()
          Unpublishes the document.
 OneResponse update(java.lang.String new_document)
          Replaces the document template contents.
 
Methods inherited from class org.opennebula.client.PoolElement
chmod, chmod, chmod, getId, getName, gid, id, processInfo, state, uid, xpath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

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.

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.

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.

OpenNebula
Cloud API

Visit OpenNebula.org
Copyright 2002-2012 © OpenNebula Project Leads (OpenNebula.org).