ReportCaster API Development at a Glance

In this section:

In order to create API code that employs ReportCaster functionality, the API calls have to be executed in a specified order.

To create API code, complete the following steps:


Top of page

x
Creating a Connection Object

How to:

Creating a connection object is the first step to writing API code. The connection object contains authentication information and context information which includes the repository location and ReportCaster Distribution Server settings.

In most cases, the code for creating a connection object is repeated, meaning that this code can be written into a convenience class or re-used. The only variables that need to be changed are host, port, user and password. Additionally, coders have a choice of authentication types: PasswordCredential, WebAuthenticateCredential, and SecurityTokenCredential. WebAuthenticateCredential allows authentication through the Web Server and SecurityTokenCredential allows authentication through cookies.

The code for creating a connection object conforms to the Sun CCI – Common Connector Interface. This architecture gives Information Builders and users the eventual flexibility to extend the product to integrate with other applications that also conform to this standard, as well as eventually integrate with features in J2EE application servers.



x
Syntax: How to Create a Connection Object

The following code demonstrates how to create a connection object using password authentication via PasswordCredential.

CasterManagedConnectionFactory managedConnectionFactory =
  new CasterManagedConnectionFactory();
managedConnectionFactory.setServerName(host);
managedConnectionFactory.setPortNumber(port);
CasterConnectionFactory connectionFactory =
  (CasterConnectionFactory)managedConnectionFactory.
  createConnectionFactory();
ConnectionSpec credential =
  new PasswordCredential(user, password.toCharArray());
CasterConnection myConnection =
  ((CasterConnection)connectionFactory.getConnection(credential));
out.println("connected");

Top of page

x
Creating a Manager Object

Once the connection object is created, you need to create at least one manager object. The ReportCaster API manager objects provide six areas of functionality: scheduling, Address Book management, user management, log management, Report Console use and library administration. Each of these areas of functionality has a manager that creates and controls the functionality, and a related package that contains the classes that handle the details of the functionality.

For example, you would use the ScheduleManager object to return a list of schedules, but you would use the classes in the ibi.broker.api.data.schedule package to manipulate the details of an individual schedule. Additionally, multiple manager objects can be created from the same connection. For example, an AddressBookManager can co-exist with a ScheduleManager.



Example: Creating a ScheduleManager Object

The following syntax demonstrates how to create a ScheduleManager Object.

//Create ScheduleManager
ScheduleManager manager = myConnection.getScheduleManager();

Top of page

x
Using Methods

How to:

Once a manager object is created, the methods that belong to that manager can be used to access or create the functionality that is required.



x
Syntax: How to Use Schedule Manager Methods

The code below demonstrates how to create a Schedule object. This is one of the detail classes in the ibi.broker.api.data.schedule package that creates a schedule with default settings, such as RUN ONCE and Priority 3, as well as whatever defaults are listed in dserver.xmls.

The other functionality required in a schedule, such as Tasks and Distribution settings, can be added to the schedule object as well.

Schedule schedule = manager.createScheduleInstanceDefault();
//set description
schedule.setDescription(scheduleDescription);
//set distribution to library
StorageLibrary distribution = new StorageLibrary();
schedule.setDistribution(distribution);
//create task
TaskWFServerProcedure task = new TaskWFServerProcedure();
task.setProcedureName(fexFileName);
task.setExecId(execId);
task.setExecPassword(execPassword);
schedule.setTaskList(new Task[]{task});

Once the components of the schedule are set, it needs to be written to the database.

//subscribe schedule
manager.addSchedule(schedule);

WebFOCUS