]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/internal/parts/UserBatchUpdateWizard.java
Improve and simplify OSGi Boot
[lgpl/argeo-commons.git] / org.argeo.security.ui.admin / src / org / argeo / security / ui / admin / internal / parts / UserBatchUpdateWizard.java
index f2038f2257acdb4d13362eb1c967edd71ef569c1..31b2042b6ec14d2ec91eabefc5f43d2af0697c50 100644 (file)
@@ -10,14 +10,14 @@ import javax.transaction.UserTransaction;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.argeo.ArgeoException;
+import org.argeo.cms.CmsException;
 import org.argeo.cms.auth.AuthConstants;
+import org.argeo.cms.util.useradmin.UserAdminUtils;
 import org.argeo.eclipse.ui.ColumnDefinition;
 import org.argeo.eclipse.ui.EclipseUiUtils;
 import org.argeo.eclipse.ui.parts.LdifUsersTable;
 import org.argeo.jcr.ArgeoNames;
 import org.argeo.osgi.useradmin.LdifName;
-import org.argeo.security.ui.admin.internal.UiAdminUtils;
 import org.argeo.security.ui.admin.internal.UserAdminWrapper;
 import org.argeo.security.ui.admin.internal.providers.CommonNameLP;
 import org.argeo.security.ui.admin.internal.providers.DomainNameLP;
@@ -97,7 +97,7 @@ public class UserBatchUpdateWizard extends Wizard {
                                                                        + "are you sure you want to proceed ?"))
                                return false;
                } catch (SystemException e) {
-                       throw new ArgeoException("Cannot get user transaction state "
+                       throw new CmsException("Cannot get user transaction state "
                                        + "before user batch update", e);
                }
 
@@ -110,7 +110,7 @@ public class UserBatchUpdateWizard extends Wizard {
                if (CMD_UPDATE_PASSWORD.equals(chooseCommandPage.getCommand())) {
                        char[] newValue = chooseCommandPage.getPwdValue();
                        if (newValue == null)
-                               throw new ArgeoException(
+                               throw new CmsException(
                                                "Password cannot be null or an empty string");
                        ResetPassword job = new ResetPassword(userAdminWrapper,
                                        userListPage.getSelectedUsers(), newValue);
@@ -139,18 +139,16 @@ public class UserBatchUpdateWizard extends Wizard {
 
                @SuppressWarnings("unchecked")
                protected void doUpdate() {
-                       UserTransaction userTransaction = userAdminWrapper
-                                       .beginTransactionIfNeeded();
+                       userAdminWrapper.beginTransactionIfNeeded();
                        try {
                                for (User user : usersToUpdate) {
                                        // the char array is emptied after being used.
                                        user.getCredentials().put(null, newPwd.clone());
                                }
-                               userTransaction.commit();
-                               UiAdminUtils.notifyTransactionStateChange(userTransaction);
+                               userAdminWrapper.commitOrNotifyTransactionStateChange();
                        } catch (Exception e) {
-                               throw new ArgeoException(
-                                               "Cannot perform batch update on users", e);
+                               throw new CmsException("Cannot perform batch update on users",
+                                               e);
                        } finally {
                                UserTransaction ut = userAdminWrapper.getUserTransaction();
                                try {
@@ -182,9 +180,9 @@ public class UserBatchUpdateWizard extends Wizard {
        // log.info("Add/Remove to group actions are not yet implemented");
        // // TODO implement this
        // // try {
-       // // throw new ArgeoException("Not yet implemented");
+       // // throw new CmsException("Not yet implemented");
        // // } catch (RepositoryException re) {
-       // // throw new ArgeoException(
+       // // throw new CmsException(
        // // "Unable to update boolean value for node " + node, re);
        // // }
        // }
@@ -222,7 +220,7 @@ public class UserBatchUpdateWizard extends Wizard {
        // }
        // userAdminWrapper.getUserTransaction().commit();
        // } catch (Exception e) {
-       // throw new ArgeoException(
+       // throw new CmsException(
        // "Cannot perform batch update on users", e);
        // } finally {
        // UserTransaction ut = userAdminWrapper.getUserTransaction();
@@ -417,7 +415,7 @@ public class UserBatchUpdateWizard extends Wizard {
                                        200));
 
                        // Only show technical DN to admin
-                       if (UiAdminUtils.isUserInRole(AuthConstants.ROLE_ADMIN))
+                       if (UserAdminUtils.isUserInRole(AuthConstants.ROLE_ADMIN))
                                columnDefs.add(new ColumnDefinition(new UserNameLP(),
                                                "Distinguished Name", 300));
 
@@ -470,7 +468,7 @@ public class UserBatchUpdateWizard extends Wizard {
                                        StringBuilder builder = new StringBuilder();
 
                                        StringBuilder tmpBuilder = new StringBuilder();
-                                       if (UiAdminUtils.notNull(filter))
+                                       if (EclipseUiUtils.notEmpty(filter))
                                                for (String prop : knownProps) {
                                                        tmpBuilder.append("(");
                                                        tmpBuilder.append(prop);
@@ -494,14 +492,14 @@ public class UserBatchUpdateWizard extends Wizard {
                                        roles = userAdminWrapper.getUserAdmin().getRoles(
                                                        builder.toString());
                                } catch (InvalidSyntaxException e) {
-                                       throw new ArgeoException(
-                                                       "Unable to get roles with filter: " + filter, e);
+                                       throw new CmsException("Unable to get roles with filter: "
+                                                       + filter, e);
                                }
                                List<User> users = new ArrayList<User>();
                                for (Role role : roles)
                                        // Prevent current logged in user to perform batch on
                                        // himself
-                                       if (!UiAdminUtils.isCurrentUser((User) role))
+                                       if (!UserAdminUtils.isCurrentUser((User) role))
                                                users.add((User) role);
                                return users;
                        }
@@ -531,7 +529,7 @@ public class UserBatchUpdateWizard extends Wizard {
                        columnDefs.add(new ColumnDefinition(new DomainNameLP(), "Domain",
                                        200));
                        // Only show technical DN to admin
-                       if (UiAdminUtils.isUserInRole(AuthConstants.ROLE_ADMIN))
+                       if (UserAdminUtils.isUserInRole(AuthConstants.ROLE_ADMIN))
                                columnDefs.add(new ColumnDefinition(new UserNameLP(),
                                                "Distinguished Name", 300));
                        userTableCmp = new ChosenUsersTableViewer(pageCmp, SWT.MULTI