}//GEN-LAST:event_btnCreateActionPerformed
protected void createUser() {
//1 - create personal group
GroupAider groupAider = null;
if(cbPersonalGroup.isSelected()) {
groupAider = new GroupAider(txtUsername.getText());
groupAider.setMetadataValue(EXistSchemaType.DESCRIPTION, "Personal group for " + txtUsername.getText());
try {
getUserManagementService().addGroup(groupAider);
} catch(final XMLDBException xmldbe) {
JOptionPane.showMessageDialog(this, "Could not create personal group '" + txtUsername.getText() + "': " + xmldbe.getMessage(), "Create User Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
//2 - create the user
final UserAider userAider = new UserAider(txtUsername.getText());
userAider.setMetadataValue(AXSchemaType.FULLNAME, txtFullName.getText());
userAider.setMetadataValue(EXistSchemaType.DESCRIPTION, txtDescription.getText());
userAider.setPassword(txtPassword.getText());
userAider.setEnabled(!cbDisabled.isSelected());
userAider.setUserMask(UmaskSpinnerModel.octalUmaskToInt((String)spnUmask.getValue()));
//add the personal group to the user
if(cbPersonalGroup.isSelected()) {
userAider.addGroup(txtUsername.getText());
}
//add any other groups to the user
final Iterator<String> itMemberOfGroups = memberOfGroupsModel.iterator();
while(itMemberOfGroups.hasNext()) {
final String memberOfGroup = itMemberOfGroups.next();
userAider.addGroup(memberOfGroup);
}
//set the primary group
try {
userAider.setPrimaryGroup(new GroupAider(getPrimaryGroup()));
} catch(final PermissionDeniedException pde) {
JOptionPane.showMessageDialog(this, "Could not set primary group '" + getPrimaryGroup() + "' of user '" + txtUsername.getText() + "': " + pde.getMessage(), "Create User Error", JOptionPane.ERROR_MESSAGE);
return;
}
try {
getUserManagementService().addAccount(userAider);
} catch(final XMLDBException xmldbe) {
JOptionPane.showMessageDialog(this, "Could not create user '" + txtUsername.getText() + "': " + xmldbe.getMessage(), "Create User Error", JOptionPane.ERROR_MESSAGE);
return;
}
//3 - if created personal group, then add us as the manager
if(cbPersonalGroup.isSelected()) {
try {
groupAider.addManager(userAider);
getUserManagementService().updateGroup(groupAider);
} catch(final XMLDBException xmldbe) {
JOptionPane.showMessageDialog(this, "Could not set user '" + txtUsername.getText() + "' as manager of personal group '" + txtUsername.getText() + "': " + xmldbe.getMessage(), "Create User Error", JOptionPane.ERROR_MESSAGE);
return;
} catch(final PermissionDeniedException pde) {