]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/internal/commands/NewUser.java
Refactor monitor and exceptions
[lgpl/argeo-commons.git] / org.argeo.security.ui.admin / src / org / argeo / security / ui / admin / internal / commands / NewUser.java
index 16e444dc5b91ac686ece74bcf86ae687358e5a2e..1a85253ad9238a4e83cc0a428c93f7141d72e19f 100644 (file)
@@ -23,14 +23,14 @@ import javax.naming.InvalidNameException;
 import javax.naming.ldap.LdapName;
 import javax.naming.ldap.Rdn;
 
-import org.argeo.ArgeoException;
+import org.argeo.cms.CmsException;
+import org.argeo.cms.util.useradmin.UserAdminUtils;
 import org.argeo.eclipse.ui.EclipseUiUtils;
 import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
 import org.argeo.jcr.ArgeoNames;
 import org.argeo.osgi.useradmin.LdifName;
 import org.argeo.osgi.useradmin.UserAdminConf;
 import org.argeo.security.ui.admin.SecurityAdminPlugin;
-import org.argeo.security.ui.admin.internal.UiAdminUtils;
 import org.argeo.security.ui.admin.internal.UserAdminWrapper;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
@@ -114,20 +114,20 @@ public class NewUser extends AbstractHandler {
                                Dictionary props = user.getProperties();
 
                                String lastNameStr = lastNameTxt.getText();
-                               if (UiAdminUtils.notNull(lastNameStr))
+                               if (EclipseUiUtils.notEmpty(lastNameStr))
                                        props.put(LdifName.sn.name(), lastNameStr);
 
                                String firstNameStr = firstNameTxt.getText();
-                               if (UiAdminUtils.notNull(firstNameStr))
+                               if (EclipseUiUtils.notEmpty(firstNameStr))
                                        props.put(LdifName.givenName.name(), firstNameStr);
 
-                               String cn = UiAdminUtils
-                                               .getDefaultCn(firstNameStr, lastNameStr);
-                               if (UiAdminUtils.notNull(cn))
+                               String cn = UserAdminUtils.buildDefaultCn(firstNameStr,
+                                               lastNameStr);
+                               if (EclipseUiUtils.notEmpty(cn))
                                        props.put(LdifName.cn.name(), cn);
 
                                String mailStr = primaryMailTxt.getText();
-                               if (UiAdminUtils.notNull(mailStr))
+                               if (EclipseUiUtils.notEmpty(mailStr))
                                        props.put(LdifName.mail.name(), mailStr);
 
                                char[] password = mainUserInfo.getPassword();
@@ -289,7 +289,7 @@ public class NewUser extends AbstractHandler {
                private void initialiseDnCmb(Combo combo) {
                        Map<String, String> dns = userAdminWrapper.getKnownBaseDns(true);
                        if (dns.isEmpty())
-                               throw new ArgeoException(
+                               throw new CmsException(
                                                "No writable base dn found. Cannot create user");
                        combo.setItems(dns.keySet().toArray(new String[0]));
                        if (dns.size() == 1)
@@ -306,7 +306,7 @@ public class NewUser extends AbstractHandler {
                                return username + "@" + (String) rdns.get(1).getValue() + '.'
                                                + (String) rdns.get(0).getValue();
                        } catch (InvalidNameException e) {
-                               throw new ArgeoException("Unable to generate mail for "
+                               throw new CmsException("Unable to generate mail for "
                                                + username + " with base dn " + baseDn, e);
                        }
                }