Goal: How to Delete User via Model API from Interstage BPM Local Store (BPM Schema)
Fact: Interstage BPM (Business Process Management) v10.1 or after
Symptom: Deleting user via com.fujitsu.iflow.model.workflow.WFAdminSession.deleteUser(String userId) does not remove the relevant user record from UserProfile table
Fix:
To properly remove all relevant user records from local store (Interstage BPM Schema),
it is required to follow the following order to delete relevant records via Model API:
Step1: delete record from UserProfile table via DirectoryServices.deleteUserPropList(String userId)
Step2: delete records from Users and UserstoGroup table via com.fujitsu.iflow.model.workflow.WFAdminSession.deleteUser(String userId)
Below is a sample code listing of how it is done. Please note that the preceding order has to be followed; otherwise, runtime error will be thrown.
//--------------------------------------------------------------------------------------------------
// Beginning of sample code listing:
public void deleteUser(String userID) throws Exception {
WFAdminSession adminSession = null;
adminSession = BPMSessionFactory.getAdminSession(); // connect new user session to server
DirectoryServices ds = null;
if (adminSession != null) {
try {
ds = WFObjectFactory.getDirectoryServices(adminSession,
adminSession.getUserName(),
HRProperties.getProperty(HRConstants.BPM_PASSWORD));
ds.deleteUserPropList(userID); // this will delete userid from UserProfile table.
adminSession.deleteUser(userID); // this will delete userid from Users and UserstoGroup table.
log("User " + userID + " is now deleted from BPM Local Store");
} catch (ModelException mex) {
log("Failed to delete user " + userID + " due to:\n" + mex.getMessage());
} finally {
adminSession.logOut();
}
}
}
// End of sample code listing
//--------------------------------------------------------------------------------------------------