Created On:  08 August 2012

Problem:

How do you list all CaliberRM projects using CaliberRM SDK using Java?

Resolution:

Below is sample Java code used to retrieve a list of all CaliberRM projects. This uses the Framework Manager method to provide faster results:

import

org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import FrameworkManagement.FrameworkManager;
import FrameworkManagement.ProjectInfo;
import com.starbase.caliber.*;
import com.starbase.caliber.server.CaliberServer;

public

class getProjects {
static Session session = null;
public static void main( String[] args) {

try
{

//Caliber server name
CaliberServer server = new CaliberServer("localhost");

//username and password
session = server.login( "admin", "admin");

System.

out.println("login successful");
System.
out.println("");

//Create FrameworkManager object to obtain Project Information
FrameworkManager myFrame=session.getRemoteFrameworkManager();

Any rv = ORB.init().create_any();

//* is wild character to return all projects
rv.insert_string("Project_p::name like '*'");

ProjectInfo[] projects = myFrame.getProjectInfo(rv);
System.

out.println (" ");
System.
out.println("No. of Projects: " + projects.length);

for(int i=0; i<>length;i++)
{
System.
out.println("");
System.
out.println("Project: " + projects.name);
System.
out.println("--------------------------------------------------------------------------");
}

}

catch( Exception e ) {
e.printStackTrace();
}
finally {
if ( session != null ) {
session.logout();
System.
out.println("Logged out");
}
}
}
}

Incident #2577637