mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Java OCA: bug in PoolElement uid() and gid() methods
This commit is contained in:
parent
099b748585
commit
c48db468e1
@ -141,9 +141,19 @@ public abstract class PoolElement {
|
||||
*/
|
||||
public int uid()
|
||||
{
|
||||
String uid = xpath("UID");
|
||||
String uid_str = xpath("UID");
|
||||
int uid_int = -1;
|
||||
|
||||
return uid != null ? Integer.parseInt( uid ) : -1;
|
||||
if ( uid_str != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
uid_int = Integer.parseInt( uid_str );
|
||||
}
|
||||
catch (NumberFormatException e) {}
|
||||
}
|
||||
|
||||
return uid_int;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -153,9 +163,19 @@ public abstract class PoolElement {
|
||||
*/
|
||||
public int gid()
|
||||
{
|
||||
String gid = xpath("GID");
|
||||
String gid_str = xpath("GID");
|
||||
int gid_int = -1;
|
||||
|
||||
return gid != null ? Integer.parseInt( gid ) : -1;
|
||||
if ( gid_str != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
gid_int = Integer.parseInt( gid_str );
|
||||
}
|
||||
catch (NumberFormatException e) {}
|
||||
}
|
||||
|
||||
return gid_int;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,7 +185,8 @@ public abstract class PoolElement {
|
||||
*
|
||||
* @param expression The XPath expression.
|
||||
* @return The String that is the result of evaluating the
|
||||
* expression and converting the result to a String. Null if
|
||||
* expression and converting the result to a String. An empty String is
|
||||
* returned if the expression is not a valid path; null if
|
||||
* the internal xml representation is not built.
|
||||
*/
|
||||
public String xpath(String expression)
|
||||
|
@ -214,6 +214,7 @@ public class TemplateTest
|
||||
assertTrue( template.gid() == 0 );
|
||||
|
||||
res = template.chown(uid, gid);
|
||||
assertTrue( !res.isError() );
|
||||
|
||||
res = template.info();
|
||||
assertTrue( !res.isError() );
|
||||
|
Loading…
x
Reference in New Issue
Block a user