Writing a simple administration application
A simple administration application typically involves a create operation for one of the following BIRT iHub objects:
*User
*Folder
*Group
To perform an administration operation that acts on an existing object in BIRT iHub System, such as a select, update, or delete operation, you must apply a search condition to the operation. To perform an administration operation that contains a set of administration operations requests, submit the request as a batch or transaction.
The following sections describe the techniques for building an application that performs a simple administration operation that creates a user in the Encyclopedia volume.
Creating a user
The following application derives from the code in the BIRT iHub Integration Technology example applications for the Apache Axis 2 client. The application class, AcCreateUser, logs in to as Administrator and creates a user. AcCreateUser.createUser( ) method performs the following tasks.
*Instantiates a com.actuate.schemas.User object using ActuateControl.newUser( ) to set the username, password, and home folder:
public class AcCreateUser {
public static void createUser(String userName, String
homeFolder) throws RemoteException {
// create a user with password same as userName
User user = actuateControl.newUser(userName,
userName, homeFolder);
User is a complex data type that represents user attributes.
*Sets additional view preference, notification, e-mail, and job priority options in the User object.
// Set user view preference to DHTML
// (defaults to DHTML in standard configuration)
user.setViewPreference(UserViewPreference.DHTML);
// set notice options
user.setSendNoticeForSuccess(new Boolean(true));
user.setSendNoticeForFailure(new Boolean(true));
// set email options
user.setSendEmailForSuccess(new Boolean(true));
user.setSendEmailForFailure(new Boolean(false));
// create fake email address UserName@localhost
user.setEmailAddress(userName + "@" + "localhost")
// assign job priority
user.setMaxJobPriority(new Long(1000));
*Calls ActuateControl.createUser( ), passing the reference to the User object.
// create the user
actuateControl.createUser(user);
System.out.println("User " + userName
+ ", view preferences, send notice and email features,
plus job priority privileges created.");
}
}
About ActuateControl.createUser( )
ActuateControl.createUser( ) performs the following tasks:
*Instantiates a com.actuate.schemas.CreateUser object.
public com.actuate.schemas.AdministrateResponse createUser(
com.actuate.schemas.User user)
throws RemoteException {
com.actuate.schemas.CreateUser createUser =
new com.actuate.schemas.CreateUser( );
The CreateUser operation is only available to a user with the Administrator role.
*Passes the reference to the User object, containing the username, password, and home folder, and other settings, to the CreateUser object.
createUser.setUser(user);
*Sets IgnoreDup to True.
createUser.setIgnoreDup(Boolean.TRUE);
If the value of IgnoreDup is True, an Encyclopedia volume ignores a duplicate request to create the user and does not report an error. If the value of IgnoreDup is False, an Encyclopedia volume ignores the duplicate request and reports the error. The default value is False. An Encyclopedia volume always rejects a duplicate request regardless of the IgnoreDup setting.
*Instantiates an AdminOperation object.
com.actuate.schemas.AdminOperation adminOperation =
new com.actuate.schemas.AdminOperation( );
An AdminOperation represents a single unit of work within an Administrate request. The list of attributes in the com.actuate.schemas. AdminOperation class lists the possible administration operations that BIRT iHub can perform within the scope of an Actuate Information Delivery API request.
*Passes the reference to the CreateUser object to AdminOperation.setCreateUser( ).
adminOperation.setCreateUser(createUser);
*Calls ActuateControl.runAdminOperation( ), returning a reference to the AdministrateResponse object that contains the Encyclopedia volume response.
return runAdminOperation(adminOperation);
}
}
About ActuateControl.runAdminOperation( )
ActuateControl.runAdminOperation( ) is an overloaded method that can assemble and run a single administration operation or an array of administration operations. The method that runs a single administration operation performs the following tasks:
*Instantiates an Administrate object.
public com.actuate.schemas.AdministrateResponse runAdminOperation(
com.actuate.schemas.AdminOperation adminOperation) {
com.actuate.schemas.Administrate administrate =
new com.actuate.schemas.Administrate( );
Administrate is not an operation on its own. It is a mechanism for assembling the set of operations that the application is requesting BIRT iHub to perform. An Administrate request can be a composite operation and consist of multiple AdminOperation objects.
*Calls administrate.setAdminOperation( ) to construct the AdminOperation array, adding the AdminOperation object as an element.
administrate.setAdminOperation(
new com.actuate.schemas.AdminOperation[ ] {
adminOperation });
The com.actuate.schemas.Administrate object is an array of AdminOperation objects that can create, update, or delete an item or items in the Encyclopedia volume. An Actuate Information Delivery API application must submit even a single AdminOperation request in an Administrate object as an array of AdminOperations. The AdminOperation array can contain one or more elements.
*Makes the remote call to the Actuate SOAP port using proxy.Administrate( ).
com.actuate.schemas.AdministrateResponse administrateResponse = null;
try {
administrateResponse = proxy.administrate(administrate);
*Handles a RemoteException.
} catch (java.rmi.RemoteException e) {
org.apache.axis.AxisFault l_fault =
org.apache.axis.AxisFault.makeFault(e);
System.out.println(l_fault.getFaultString( ));
System.out.println(l_fault.getFaultCode().toString( ));
org.w3c.dom.Element[ ] l_details =
l_fault.getFaultDetails( );
}
*Returns a reference to the com.actuate.schemas.AdministrateResponse object.
return administrateResponse;}