This sample demonstrates how to set email notification for all users added to the workflow system. Run the sample by entering a command similar to the following:
java UserInfoSample username password <server name>:<port number>/<router instance name> email_suffix
Note For a detailed explanation of the command line, see the Run the sample application section of the Run the Unmodified Samples topic.
The main method displays a usage line if you supply less than four arguments; otherwise, the method passes the arguments to the constructor for the sample. The constructor UserInfoSample(String user, String pw, String router, String email_suffix) performs common exception handling and sets user information properties for email notification. This sample operates in the general order listed below.
Create an instance of the session object. Create the security list object from the session object. In the code below, each fetch to the security list object returns 1000 elements, and the false argument causes the list to consist of users, only, to exclude groups.
session = new VWSession(user, pw, router);
VWSecurityList sl = session.fetchUsers(1000, false);
while (sl.hasNext()){
Create an instance of a user information object from the session and an element of the security list object, using VWSession.fetchUserInfo(String). The returned security list object is cast to a String for use as an argument.
VWUserInfo ui = session.fetchUserInfo((String)sl.next());
Print the email address and set it with the VWUserInfo.setEMailAddress(String) method.
System.out.println(ui.getName() + email_suffix);
ui.setEMailAddress(ui.getName() + email_suffix);
This step occurs within a while loop for instructional reasons. In production, the same value should be set one time before the while loop to reduce runtime redundancy and to perform more efficiently.
Create a combination notification flag for this user to be notified by email, as various events occur. The flags are combined by performing a bitwise or of each value to be included.
int nf = VWUserInfo.NOTIFICATION_STEP_EXPIRED_DEADLINE |
VWUserInfo.NOTIFICATION_STEP_NEW_ASSIGNMENT |
VWUserInfo.NOTIFICATION_STEP_REMINDERS |
VWUserInfo.NOTIFICATION_TRACKER_EXPIRED_DEADLINE |
VWUserInfo.NOTIFICATION_TRACKER_NEW_ASSIGNMENT |
VWUserInfo.NOTIFICATION_TRACKER_WORKFLOW_EXCEPTION;
Set the notification flags and save the user information with VWUserInfo methods:
ui.setNotificationFlags(nf);
ui.save();
}
Additional code in this sample performs common error handling and cleanup.