diff --git a/src/oca/java/src/org/opennebula/client/Client.java b/src/oca/java/src/org/opennebula/client/Client.java index c6d987e531..6c06e92cf4 100644 --- a/src/oca/java/src/org/opennebula/client/Client.java +++ b/src/oca/java/src/org/opennebula/client/Client.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,6 +19,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; +import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.security.MessageDigest; @@ -41,15 +42,14 @@ public class Client{ //-------------------------------------------------------------------------- /** - * Creates a new xml-rpc client with default options: - * the auth. file will be assumed to be at $ONE_AUTH, and - * the endpoint will be set to $ONE_XMLRPC. - *
+ * Creates a new xml-rpc client with default options: the auth. file will be + * assumed to be at $ONE_AUTH, and the endpoint will be set to $ONE_XMLRPC.
* It is the equivalent of Client(null, null). * - * @throws Exception if one authorization file cannot be located. + * @throws ClientConfigurationException + * if the default configuration options are invalid. */ - public Client() throws Exception + public Client() throws ClientConfigurationException { setOneAuth(null); setOneEndPoint(null); @@ -58,13 +58,16 @@ public class Client{ /** * Creates a new xml-rpc client with specified options. * - * @param secret A string containing the ONE user:password tuple. - * Can be null - * @param endpoint Where the rpc server is listening, must be something - * like "http://localhost:2633/RPC2". Can be null - * @throws Exception if the authorization options are invalid + * @param secret + * A string containing the ONE user:password tuple. Can be null + * @param endpoint + * Where the rpc server is listening, must be something like + * "http://localhost:2633/RPC2". Can be null + * @throws ClientConfigurationException + * if the configuration options are invalid */ - public Client(String secret, String endpoint) throws Exception + public Client(String secret, String endpoint) + throws ClientConfigurationException { setOneAuth(secret); setOneEndPoint(endpoint); @@ -129,7 +132,7 @@ public class Client{ private XmlRpcClient client; - private void setOneAuth(String secret) throws Exception + private void setOneAuth(String secret) throws ClientConfigurationException { String oneSecret = secret; @@ -157,7 +160,8 @@ public class Client{ if(token.length != 2 ) { - throw new Exception("Wrong format for authorization string: " + throw new ClientConfigurationException( + "Wrong format for authorization string: " + oneSecret + "\nFormat expected is user:password"); } @@ -182,15 +186,26 @@ public class Client{ } catch (FileNotFoundException e) { - throw new Exception("ONE_AUTH file not present"); + // This comes first, since it is a special case of IOException + throw new ClientConfigurationException("ONE_AUTH file not present"); + } + catch (IOException e) + { + // You could have the file but for some reason the program can not + // read it + throw new ClientConfigurationException("ONE_AUTH file unreadable"); } catch (NoSuchAlgorithmException e) { - throw new Exception("Error initializing MessageDigest with SHA-1"); + // A client application cannot recover if the SHA-1 digest + // algorithm cannot be initialized + throw new RuntimeException( + "Error initializing MessageDigest with SHA-1", e); } } - private void setOneEndPoint(String endpoint) throws Exception + private void setOneEndPoint(String endpoint) + throws ClientConfigurationException { oneEndPoint = "http://localhost:2633/RPC2"; @@ -216,7 +231,8 @@ public class Client{ } catch (MalformedURLException e) { - throw new Exception("The URL "+oneEndPoint+" is malformed."); + throw new ClientConfigurationException( + "The URL "+oneEndPoint+" is malformed."); } client = new XmlRpcClient(); diff --git a/src/oca/java/src/org/opennebula/client/ClientConfigurationException.java b/src/oca/java/src/org/opennebula/client/ClientConfigurationException.java new file mode 100644 index 0000000000..acc44e9a4a --- /dev/null +++ b/src/oca/java/src/org/opennebula/client/ClientConfigurationException.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +package org.opennebula.client; + +/** + * This exception is thrown when a a new Client is constructed with wrong + * authorization options. + */ +public class ClientConfigurationException extends OneException +{ + private static final long serialVersionUID = -3220098130946406458L; + + public ClientConfigurationException(String message) + { + super(message); + } +} \ No newline at end of file diff --git a/src/oca/java/src/org/opennebula/client/OneException.java b/src/oca/java/src/org/opennebula/client/OneException.java new file mode 100644 index 0000000000..d77dfd556a --- /dev/null +++ b/src/oca/java/src/org/opennebula/client/OneException.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +package org.opennebula.client; + +/** + * The OneException class is a generic OpenNebula exception. + */ +public class OneException extends Exception +{ + private static final long serialVersionUID = -2281517151282894589L; + + public OneException(String message) + { + super(message); + } +} \ No newline at end of file diff --git a/src/oca/java/src/org/opennebula/client/Pool.java b/src/oca/java/src/org/opennebula/client/Pool.java index 9bd7a85d8a..39391828d9 100644 --- a/src/oca/java/src/org/opennebula/client/Pool.java +++ b/src/oca/java/src/org/opennebula/client/Pool.java @@ -37,16 +37,35 @@ public abstract class Pool{ protected Client client; protected String elementName; + protected String infoMethod; protected NodeList poolElements; /** - * Sets the Pool attributes. + * All resources in the pool + */ + public final static int ALL = -2; + + /** + * Connected user's resources + */ + public final static int MINE = -3; + + /** + * Connected user's resources, and the ones in his group + */ + public final static int MINE_GROUP = -1; + + /** + * Protected constructor, to be called from subclasses. + * * @param elementName Name of the PoolElement's xml element * @param client XML-RPC client which will handle calls + * @param infoMethod XML-RPC info method for the subclass Pool */ - protected Pool(String elementName, Client client) + protected Pool(String elementName, Client client, String infoMethod) { this.elementName = elementName; + this.infoMethod = infoMethod; this.client = client; } @@ -59,6 +78,76 @@ public abstract class Pool{ */ public abstract PoolElement factory(Node node); + /*************************************************************************** + * Info methods + **************************************************************************/ + + protected static OneResponse info(Client client, String infoMethod) + { + return xmlrpcInfo(client, infoMethod); + } + + protected static OneResponse info(Client client, String infoMethod, + int filter, int startId, int endId) + { + return xmlrpcInfo(client, infoMethod, filter, startId, endId); + } + + protected static OneResponse infoAll(Client client, String infoMethod) + { + return xmlrpcInfo(client, infoMethod, ALL, -1, -1); + } + + protected static OneResponse infoMine(Client client, String infoMethod) + { + return xmlrpcInfo(client, infoMethod, MINE, -1, -1); + } + + protected static OneResponse infoGroup(Client client, String infoMethod) + { + return xmlrpcInfo(client, infoMethod, MINE_GROUP, -1, -1); + } + + private static OneResponse xmlrpcInfo(Client client, String infoMethod, Object...args) + { + return client.call(infoMethod, args); + } + + protected OneResponse info() + { + OneResponse response = info(client, infoMethod); + processInfo(response); + return response; + } + + protected OneResponse infoAll() + { + OneResponse response = infoAll(client, infoMethod); + processInfo(response); + return response; + } + + protected OneResponse infoMine() + { + OneResponse response = infoMine(client, infoMethod); + processInfo(response); + return response; + } + + protected OneResponse infoGroup() + { + OneResponse response = infoGroup(client, infoMethod); + processInfo(response); + return response; + } + + protected OneResponse info(int filter, int startId, int endId) + { + OneResponse response = info(client, infoMethod, filter, startId, endId); + processInfo(response); + return response; + } + /** * After a *pool.info call, this method builds the internal xml * representation of the pool. @@ -114,6 +203,13 @@ public abstract class Pool{ return theElement; } + /** + * Returns the element with the given Id from the pool. If it is not found, + * then returns null. + * + * @param id of the element to retrieve + * @return The element with the given Id, or null if it was not found. + */ protected PoolElement getById(int id) { // TODO: Use xpath to find the element //ID diff --git a/src/oca/java/src/org/opennebula/client/acl/Acl.java b/src/oca/java/src/org/opennebula/client/acl/Acl.java index 62d2f1d560..357d40563d 100644 --- a/src/oca/java/src/org/opennebula/client/acl/Acl.java +++ b/src/oca/java/src/org/opennebula/client/acl/Acl.java @@ -136,8 +136,10 @@ public class Acl extends PoolElement{ * @param rule a rule string, e.g. "#5 HOST+VM/@12 INFO+CREATE+DELETE" * @return If successful the message contains the associated * id generated for this rule. + * @throws RuleParseException If the rule syntax is wrong. */ public static OneResponse allocate(Client client, String rule) + throws RuleParseException { String[] components = parseRule(rule); return allocate(client, components[0], components[1], components[2]); @@ -236,8 +238,9 @@ public class Acl extends PoolElement{ * * @param rule an ACL rule in string format * @return an Array containing 3 Strings (hex 64b numbers) + * @throws RuleParseException If the rule syntax is wrong. */ - public static String[] parseRule(String rule) + public static String[] parseRule(String rule) throws RuleParseException { String [] ret = new String[3]; @@ -245,8 +248,8 @@ public class Acl extends PoolElement{ if( components.length != 3 ) { - // TODO: throw "String needs three components: User, Resource, Rights" - return ret; + throw new RuleParseException( + "String needs three components: User, Resource, Rights"); } ret[0] = parseUsers(components[0]); @@ -262,7 +265,7 @@ public class Acl extends PoolElement{ * @param users Users component string * @return A string containing a hex number */ - private static String parseUsers(String users) + private static String parseUsers(String users) throws RuleParseException { return Long.toHexString( calculateIds(users) ); } @@ -274,14 +277,14 @@ public class Acl extends PoolElement{ * @return A string containing a hex number */ private static String parseResources(String resources) + throws RuleParseException { long ret = 0; String[] resourcesComponents = resources.split("/"); if( resourcesComponents.length != 2 ) { - // TODO: throw "Resource '#{resources}' malformed" - return ""; + throw new RuleParseException("Resource '"+resources+"' malformed"); } for( String resource : resourcesComponents[0].split("\\+") ) @@ -290,7 +293,8 @@ public class Acl extends PoolElement{ if( !RESOURCES.containsKey(resource) ) { - // TODO: throw "Resource '#{resource}' does not exist" + throw new RuleParseException("Resource '" + resource + + "' does not exist"); } ret += RESOURCES.get(resource); @@ -307,7 +311,7 @@ public class Acl extends PoolElement{ * @param rights Rights component string * @return A string containing a hex number */ - private static String parseRights(String rights) + private static String parseRights(String rights) throws RuleParseException { long ret = 0; @@ -318,8 +322,8 @@ public class Acl extends PoolElement{ if( !RIGHTS.containsKey(right) ) { - // TODO throw "Right '#{right}' does not exist" - return ""; + throw new RuleParseException("Right '" + right + + "' does not exist"); } ret += RIGHTS.get(right); @@ -335,12 +339,11 @@ public class Acl extends PoolElement{ * @param id Rule Id string * @return the numeric value for the given id_str */ - private static long calculateIds(String id) + private static long calculateIds(String id) throws RuleParseException { if( !id.matches("^([#@]\\d+|\\*)$") ) { - // TODO: throw "ID string '#{id_str}' malformed" - return 0; + throw new RuleParseException("ID string '" + id + "' malformed"); } long value = USERS.get( "" + id.charAt(0) ); diff --git a/src/oca/java/src/org/opennebula/client/acl/AclPool.java b/src/oca/java/src/org/opennebula/client/acl/AclPool.java index 22c6ddab1a..09c3b4f91b 100644 --- a/src/oca/java/src/org/opennebula/client/acl/AclPool.java +++ b/src/oca/java/src/org/opennebula/client/acl/AclPool.java @@ -40,7 +40,7 @@ public class AclPool extends Pool implements Iterable{ */ public AclPool(Client client) { - super(ELEMENT_NAME, client); + super(ELEMENT_NAME, client, INFO_METHOD); } @Override @@ -58,7 +58,7 @@ public class AclPool extends Pool implements Iterable{ */ public static OneResponse info(Client client) { - return client.call(INFO_METHOD); + return Pool.info(client, INFO_METHOD); } /** @@ -68,9 +68,7 @@ public class AclPool extends Pool implements Iterable{ */ public OneResponse info() { - OneResponse response = info(client); - super.processInfo(response); - return response; + return super.info(); } public Iterator iterator() @@ -91,6 +89,13 @@ public class AclPool extends Pool implements Iterable{ return ab.iterator(); } + /** + * Returns the ACl rule with the given Id from the pool. If it is not found, + * then returns null. + * + * @param id of the ACl rule to retrieve + * @return The ACl rule with the given Id, or null if it was not found. + */ public Acl getById(int id) { return (Acl) super.getById(id); diff --git a/src/oca/java/src/org/opennebula/client/acl/RuleParseException.java b/src/oca/java/src/org/opennebula/client/acl/RuleParseException.java new file mode 100644 index 0000000000..2ae5590291 --- /dev/null +++ b/src/oca/java/src/org/opennebula/client/acl/RuleParseException.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +package org.opennebula.client.acl; + +import org.opennebula.client.OneException; + +public class RuleParseException extends OneException +{ + private static final long serialVersionUID = 5992480039195389371L; + + public RuleParseException(String message) + { + super(message); + } +} diff --git a/src/oca/java/src/org/opennebula/client/group/GroupPool.java b/src/oca/java/src/org/opennebula/client/group/GroupPool.java index 74038a2d4a..f05c0f3a86 100644 --- a/src/oca/java/src/org/opennebula/client/group/GroupPool.java +++ b/src/oca/java/src/org/opennebula/client/group/GroupPool.java @@ -40,7 +40,7 @@ public class GroupPool extends Pool implements Iterable{ */ public GroupPool(Client client) { - super(ELEMENT_NAME, client); + super(ELEMENT_NAME, client, INFO_METHOD); } @Override @@ -58,7 +58,7 @@ public class GroupPool extends Pool implements Iterable{ */ public static OneResponse info(Client client) { - return client.call(INFO_METHOD); + return Pool.info(client, INFO_METHOD); } /** @@ -68,9 +68,7 @@ public class GroupPool extends Pool implements Iterable{ */ public OneResponse info() { - OneResponse response = info(client); - super.processInfo(response); - return response; + return super.info(); } public Iterator iterator() @@ -90,4 +88,16 @@ public class GroupPool extends Pool implements Iterable{ return ab.iterator(); } + + /** + * Returns the Group with the given Id from the pool. If it is not found, + * then returns null. + * + * @param id of the Group to retrieve + * @return The Image with the given Id, or null if it was not found. + */ + public Group getById(int id) + { + return (Group) super.getById(id); + } } diff --git a/src/oca/java/src/org/opennebula/client/host/HostPool.java b/src/oca/java/src/org/opennebula/client/host/HostPool.java index 30de30d744..6dac87fe6a 100644 --- a/src/oca/java/src/org/opennebula/client/host/HostPool.java +++ b/src/oca/java/src/org/opennebula/client/host/HostPool.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,7 +40,7 @@ public class HostPool extends Pool implements Iterable{ */ public HostPool(Client client) { - super(ELEMENT_NAME, client); + super(ELEMENT_NAME, client, INFO_METHOD); } @Override @@ -51,26 +51,24 @@ public class HostPool extends Pool implements Iterable{ /** * Retrieves all the hosts in the pool. - * + * * @param client XML-RPC Client. * @return If successful the message contains the string * with the information returned by OpenNebula. */ public static OneResponse info(Client client) { - return client.call(INFO_METHOD); + return Pool.info(client, INFO_METHOD); } /** * Loads the xml representation of the host pool. - * + * * @see HostPool#info(Client) */ public OneResponse info() { - OneResponse response = info(client); - super.processInfo(response); - return response; + return super.info(); } public Iterator iterator() @@ -90,4 +88,16 @@ public class HostPool extends Pool implements Iterable{ return ab.iterator(); } + + /** + * Returns the Host with the given Id from the pool. If it is not found, + * then returns null. + * + * @param id of the Host to retrieve + * @return The Image with the given Id, or null if it was not found. + */ + public Host getById(int id) + { + return (Host) super.getById(id); + } } diff --git a/src/oca/java/src/org/opennebula/client/image/ImagePool.java b/src/oca/java/src/org/opennebula/client/image/ImagePool.java index a571ac33ab..ad5153c898 100644 --- a/src/oca/java/src/org/opennebula/client/image/ImagePool.java +++ b/src/oca/java/src/org/opennebula/client/image/ImagePool.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,33 +37,36 @@ public class ImagePool extends Pool implements Iterable /** * Creates a new Image pool with the default filter flag value - * set to 0 (Images belonging to user with UID 0) - * + * set to {@link Pool#MINE_GROUP} (Images belonging to the connected user, + * and the ones in his group) + * * @param client XML-RPC Client. - * + * * @see ImagePool#ImagePool(Client, int) */ public ImagePool(Client client) { - super(ELEMENT_NAME, client); - this.filter = 0; + super(ELEMENT_NAME, client, INFO_METHOD); + this.filter = MINE_GROUP; } /** * Creates a new Image pool. - * + * * @param client XML-RPC Client. - * @param filter Filter flag used by default in the method + * @param filter Filter flag to use by default in the method * {@link ImagePool#info()}. Possible values: *
    - *
  • <= -2: All Images
  • - *
  • -1: Connected user's Images and public ones
  • + *
  • {@link Pool#ALL}: All Images
  • + *
  • {@link Pool#MINE}: Connected user's Images
  • + *
  • {@link Pool#MINE_GROUP}: Connected user's Images, and the ones in + * his group
  • *
  • >= 0: UID User's Images
  • *
*/ public ImagePool(Client client, int filter) { - super(ELEMENT_NAME, client); + super(ELEMENT_NAME, client, INFO_METHOD); this.filter = filter; } @@ -77,14 +80,15 @@ public class ImagePool extends Pool implements Iterable } /** - * Retrieves all or part of the images in the pool. - * + * Retrieves all or part of the Images in the pool. + * * @param client XML-RPC Client. - * @param filter Filter flag used by default in the method - * {@link ImagePool#info()}. Possible values: + * @param filter Filter flag to use. Possible values: *
    - *
  • <= -2: All Images
  • - *
  • -1: Connected user's Images and public ones
  • + *
  • {@link Pool#ALL}: All Images
  • + *
  • {@link Pool#MINE}: Connected user's Images
  • + *
  • {@link Pool#MINE_GROUP}: Connected user's Images, and the ones in + * his group
  • *
  • >= 0: UID User's Images
  • *
* @return If successful the message contains the string @@ -92,24 +96,139 @@ public class ImagePool extends Pool implements Iterable */ public static OneResponse info(Client client, int filter) { - return client.call(INFO_METHOD, filter); + return Pool.info(client, INFO_METHOD, filter, -1, -1); + } + + /** + * Retrieves all the Images in the pool. + * + * @param client XML-RPC Client. + * @return If successful the message contains the string + * with the information returned by OpenNebula. + */ + public static OneResponse infoAll(Client client) + { + return Pool.infoAll(client, INFO_METHOD); + } + + /** + * Retrieves all the connected user's Images. + * + * @param client XML-RPC Client. + * @return If successful the message contains the string + * with the information returned by OpenNebula. + */ + public static OneResponse infoMine(Client client) + { + return Pool.infoMine(client, INFO_METHOD); + } + + /** + * Retrieves all the connected user's Images and the ones in + * his group. + * + * @param client XML-RPC Client. + * @return If successful the message contains the string + * with the information returned by OpenNebula. + */ + public static OneResponse infoGroup(Client client) + { + return Pool.infoGroup(client, INFO_METHOD); + } + + /** + * Retrieves all or part of the Images in the pool. The Images to retrieve + * can be also filtered by Id, specifying the first and last Id to include. + * + * @param client XML-RPC Client. + * @param filter Filter flag to use. Possible values: + *
    + *
  • {@link Pool#ALL}: All Images
  • + *
  • {@link Pool#MINE}: Connected user's Images
  • + *
  • {@link Pool#MINE_GROUP}: Connected user's Images, and the ones in + * his group
  • + *
  • >= 0: UID User's Images
  • + *
+ * @param startId Lowest Id to retrieve + * @param endId Biggest Id to retrieve + * @return If successful the message contains the string + * with the information returned by OpenNebula. + */ + public static OneResponse info(Client client, int filter, + int startId, int endId) + { + return Pool.info(client, INFO_METHOD, filter, startId, endId); } /** * Loads the xml representation of all or part of the * Images in the pool. The filter used is the one set in * the constructor. - * + * * @see ImagePool#info(Client, int) - * + * * @return If successful the message contains the string * with the information returned by OpenNebula. */ public OneResponse info() { - OneResponse response = info(client, filter); - super.processInfo(response); - return response; + return super.info(filter, -1, -1); + } + + /** + * Loads the xml representation of all the Images in the pool. + * + * @return If successful the message contains the string + * with the information returned by OpenNebula. + */ + public OneResponse infoAll() + { + return super.infoAll(); + } + + /** + * Loads the xml representation of all the connected user's Images. + * + * @return If successful the message contains the string + * with the information returned by OpenNebula. + */ + public OneResponse infoMine() + { + return super.infoMine(); + } + + /** + * Loads the xml representation of all the connected user's Images and + * the ones in his group. + * + * @return If successful the message contains the string + * with the information returned by OpenNebula. + */ + public OneResponse infoGroup() + { + return super.infoGroup(); + } + + /** + * Retrieves all or part of the Images in the pool. The Images to retrieve + * can be also filtered by Id, specifying the first and last Id to include. + * + * @param filter Filter flag to use. Possible values: + *
    + *
  • {@link Pool#ALL}: All Images
  • + *
  • {@link Pool#MINE}: Connected user's Images
  • + *
  • {@link Pool#MINE_GROUP}: Connected user's Images, and the ones in + * his group
  • + *
  • >= 0: UID User's Images
  • + *
+ * @param startId Lowest Id to retrieve + * @param endId Biggest Id to retrieve + * @return If successful the message contains the string + * with the information returned by OpenNebula. + */ + public OneResponse info(int filter, int startId, int endId) + { + return super.info(filter, startId, endId); } public Iterator iterator() @@ -129,4 +248,16 @@ public class ImagePool extends Pool implements Iterable return ab.iterator(); } + + /** + * Returns the Image with the given Id from the pool. If it is not found, + * then returns null. + * + * @param id of the Image to retrieve + * @return The Image with the given Id, or null if it was not found. + */ + public Image getById(int id) + { + return (Image) super.getById(id); + } } diff --git a/src/oca/java/src/org/opennebula/client/template/TemplatePool.java b/src/oca/java/src/org/opennebula/client/template/TemplatePool.java index 4d95e5dcee..12c9a17495 100644 --- a/src/oca/java/src/org/opennebula/client/template/TemplatePool.java +++ b/src/oca/java/src/org/opennebula/client/template/TemplatePool.java @@ -37,7 +37,8 @@ public class TemplatePool extends Pool implements Iterable