Pages

Tuesday, December 18, 2012

UserManager : Modify User Code

We can now look into modifying existing users.

1) Code

public void modifyUser(OIMClient oimclient){
UserManager usrMgr = oimclient.getService(UserManager.class);
User user = new User("65"); //Pass the user_key while creating [Can be obtained using a search]
user.setAttribute("First Name", "APIUser_FName");
user.setAttribute("Last Name", "APIUser_LName");
try {
usrMgr.modify(user);
} catch (ValidationFailedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UserModifyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchUserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AccessDeniedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

2) Result



3) Alternates

usrMgr.modify("Email", "APIUSER1@MAIL.COM", user);

Where the first two parameters are the search condition. All users who satisfy the condition will be modified.


modify(java.util.ArrayList userIDs, java.util.HashMap args, boolean isUserLogin)

We can pass a list of userIds to be modified. 
The hashmap contains the attribute names and values to be modified.
isUserLogin should be set to true if the userIds list contains the User Logins, else use false if they are user key values.


No comments:

Post a Comment