Adapt commands to the new security model.
authorBruno Sinou <bsinou@argeo.org>
Fri, 11 Sep 2015 14:09:46 +0000 (14:09 +0000)
committerBruno Sinou <bsinou@argeo.org>
Fri, 11 Sep 2015 14:09:46 +0000 (14:09 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@8385 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

20 files changed:
org.argeo.security.ui.admin/META-INF/spring/commands.xml
org.argeo.security.ui.admin/plugin.xml
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/AddRole.java [deleted file]
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/DeleteGroups.java [new file with mode: 0644]
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/DeleteRole.java [deleted file]
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/DeleteUser.java [deleted file]
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/DeleteUsers.java [new file with mode: 0644]
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/ForceRefresh.java [new file with mode: 0644]
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/NewGroup.java [new file with mode: 0644]
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/NewUser.java
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/OpenArgeoUserEditor.java [deleted file]
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/RefreshRoles.java [deleted file]
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/RefreshUsersList.java [deleted file]
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/SaveArgeoUser.java
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/UserBatchUpdate.java
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/editors/DefaultUserMainPage.java
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/editors/JcrArgeoUserEditor.java [deleted file]
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/editors/UserEditor.java
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/internal/UiAdminUtils.java
org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/views/GroupsView.java

index 94dff3fc2e89b19bd9860e929f7649557fa2eb67..e83440376b2bdc22dd7ec6b7009aaa1ff4a4510b 100644 (file)
@@ -6,7 +6,12 @@
 
        <!-- <bean id="openArgeoUserEditor" class="org.argeo.security.ui.admin.commands.OpenArgeoUserEditor" 
                scope="prototype" /> -->
+
        <!-- USERS -->
+       <bean id="newUser" class="org.argeo.security.ui.admin.commands.NewUser"
+               scope="prototype">
+               <property name="userAdmin" ref="userAdmin" />
+       </bean>
        <!-- <bean id="newUser" class="org.argeo.security.ui.admin.commands.NewUser" 
                scope="prototype"> <property name="repository" ref="nodeRepository" /> <property 
                name="userAdminService" ref="userAdminService" /> </bean> <bean id="refreshUsersList" 
index fe52cd0fcb6b065a046352e4b6cc514fb1ef4fb9..b8ad0300024b8ec28ca15fff96f9b5bff22ccdd9 100644 (file)
             name="Groups"
             restorable="false">
       </view>
-      
-      <!-- Legacy -->
-      <!-- <view
-            class="org.argeo.eclipse.spring.SpringExtensionFactory"
-            icon="icons/users.gif"
-            id="org.argeo.security.ui.admin.jcrUsersView"
-            name="Users"
-            restorable="false">
-      </view>
-      <view
-            class="org.argeo.eclipse.spring.SpringExtensionFactory"
-            icon="icons/role.gif"
-            id="org.argeo.security.ui.admin.jcrRolesView"
-            name="Roles"
-            restorable="false">
-      </view>-->
-       </extension> 
+    </extension> 
        
        <!-- Editors -->
        <extension
     
     <extension
          point="org.eclipse.ui.commands">
+       <command
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            id="org.argeo.security.ui.admin.newUser"
+            name="New User">
+       </command>
+      <command
+            defaultHandler="org.argeo.security.ui.admin.commands.DeleteUsers"
+            id="org.argeo.security.ui.admin.deleteUsers"
+            name="Delete User">
+      </command>
+      <command
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            id="org.argeo.security.ui.admin.newGroup"
+            name="New Group">
+      </command>
+      <command
+            defaultHandler="org.argeo.security.ui.admin.commands.DeleteGroups"
+            id="org.argeo.security.ui.admin.deleteGroups"
+            name="Delete Group">
+      </command>
+
+         <!-- Force the refresh when the various listener are not enough -->
+      <command
+            defaultHandler="org.argeo.security.ui.admin.commands.ForceRefresh"
+            id="org.argeo.security.ui.admin.forceRefresh"
+            name="Force Refresh">
+      </command>
       <!--<command
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
             id="org.argeo.security.ui.admin.openArgeoUserEditor"
     </extension>
      <extension
          point="org.eclipse.ui.menus">
+         <menuContribution
+            locationURI="toolbar:org.argeo.security.ui.admin.usersView">
+            <command
+                  commandId="org.argeo.security.ui.admin.deleteUsers"
+                  icon="icons/remove.gif"
+                  label="Delete User"
+                  tooltip="Delete selected users">
+            </command>
+            <command
+                  commandId="org.argeo.security.ui.admin.forceRefresh"
+                  icon="icons/refresh.png"
+                  label="Refresh list"
+                  tooltip="Force the full refresh of the user list">
+            </command>
+            <command
+                  commandId="org.argeo.security.ui.admin.newUser"
+                  icon="icons/add.gif"
+                  label="Add User"
+                  tooltip="Create a new user">
+            </command>
+            <!--<command
+                  commandId="org.argeo.security.ui.admin.userBatchUpdate"
+                  icon="icons/batch.gif"
+                  label="Update users"
+                  tooltip="Perform maintenance activities on a list of chosen users">
+            </command>-->
+        </menuContribution>
+        <menuContribution
+            locationURI="toolbar:org.argeo.security.ui.admin.groupsView">
+            <command
+                  commandId="org.argeo.security.ui.admin.deleteGroups"
+                  icon="icons/remove.gif"
+                  label="Delete Group"
+                  tooltip="Delete selected groups">
+            </command>
+            <command
+                  commandId="org.argeo.security.ui.admin.forceRefresh"
+                  icon="icons/refresh.png"
+                  label="Refresh list"
+                  tooltip="Force the full refresh of the group list">
+            </command>
+            <command
+                  commandId="org.argeo.security.ui.admin.newGroup"
+                  icon="icons/add.gif"
+                  label="Add Group"
+                  tooltip="Create a new group">
+            </command>
+        </menuContribution>
+         
 <!--           <menuContribution
             locationURI="toolbar:org.argeo.security.ui.admin.adminRolesView">
             <command
diff --git a/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/AddRole.java b/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/AddRole.java
deleted file mode 100644 (file)
index c91f81a..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.admin.commands;
-
-import org.argeo.security.UserAdminService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/** Add a new role. */
-public class AddRole extends AbstractHandler {
-       public final static String COMMAND_ID = "org.argeo.security.ui.admin.addRole";
-       private UserAdminService userAdminService;
-       private String rolePrefix = "ROLE_";
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               return null;
-       }
-
-       public void setUserAdminService(UserAdminService userAdminService) {
-               this.userAdminService = userAdminService;
-       }
-}
-// JcrRolesView rolesView = (JcrRolesView) HandlerUtil
-// .getActiveWorkbenchWindow(event).getActivePage()
-// .findView(JcrRolesView.ID);
-// String role = rolesView.getNewRole();
-// if (role.trim().equals(""))
-// return null;
-// if (role.equals(rolesView.getAddNewRoleText()))
-// return null;
-// role = role.trim().toUpperCase();
-// if (!role.startsWith(rolePrefix))
-// role = rolePrefix + role;
-// if (userAdminService.listEditableRoles().contains(role))
-// throw new ArgeoException("Role " + role + " already exists");
-// userAdminService.newRole(role);
-// rolesView.refresh();
-//
-// // refresh editors
-// IEditorReference[] refs = HandlerUtil.getActiveWorkbenchWindow(event)
-// .getActivePage()
-// .findEditors(null, JcrArgeoUserEditor.ID, IWorkbenchPage.MATCH_ID);
-// for (IEditorReference ref : refs) {
-// JcrArgeoUserEditor userEditor = (JcrArgeoUserEditor) ref.getEditor(false);
-// if (userEditor != null) {
-// userEditor.refresh();
-// }
-// }
-// return null;
-// }
-//
-// public void setUserAdminService(UserAdminService userAdminService) {
-// this.userAdminService = userAdminService;
-// }
-//
-// }
diff --git a/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/DeleteGroups.java b/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/DeleteGroups.java
new file mode 100644 (file)
index 0000000..b655cd1
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.security.ui.admin.commands;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.argeo.security.ui.admin.SecurityAdminPlugin;
+import org.argeo.security.ui.admin.internal.UiAdminUtils;
+import org.argeo.security.ui.admin.internal.UserAdminConstants;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.osgi.service.useradmin.Group;
+
+/** Deletes the selected groups */
+public class DeleteGroups extends AbstractHandler {
+       public final static String ID = SecurityAdminPlugin.PLUGIN_ID + ".deleteGroups";
+
+       
+       @SuppressWarnings("unchecked")
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               ISelection selection = HandlerUtil.getCurrentSelection(event);
+               if (selection.isEmpty())
+                       return null;
+
+               Map<String, Group> toDelete = new TreeMap<String, Group>();
+               Iterator<Group> it = ((IStructuredSelection) selection).iterator();
+               groups: while (it.hasNext()) {
+                       Group currGroup = it.next();
+                       String groupName = UiAdminUtils.getProperty(currGroup,
+                                       UserAdminConstants.KEY_CN);
+
+                       // TODO add checks
+                       // if (userName.equals(profileNode.getSession().getUserID())) {
+                       // log.warn("Cannot delete its own user: " + userName);
+                       // continue groups;
+                       // }
+                       toDelete.put(groupName, currGroup);
+               }
+
+               if (!MessageDialog
+                               .openQuestion(
+                                               HandlerUtil.getActiveShell(event),
+                                               "Delete Groups",
+                                               "Are you sure that you want to delete groups "
+                                                               + toDelete.keySet()
+                                                               + "?\n"
+                                                               + "This might lead to inconsistencies in the application."))
+                       return null;
+
+               for (String groupName : toDelete.keySet()) {
+               }
+               MessageDialog.openInformation(HandlerUtil.getActiveShell(event),
+                               "Unimplemented method",
+                               "The effective deletion is not yet implemented");
+               // TODO refresh?
+               // JcrUsersView view = (JcrUsersView) HandlerUtil
+               // .getActiveWorkbenchWindow(event).getActivePage()
+               // .findView(JcrUsersView.ID);
+               // view.refresh();
+               return null;
+       }
+
+       // public void setUserAdmin(UserAdmin userAdmin) {
+       // this.userAdmin = userAdmin;
+       // }
+}
\ No newline at end of file
diff --git a/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/DeleteRole.java b/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/DeleteRole.java
deleted file mode 100644 (file)
index a8db0eb..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.admin.commands;
-
-import org.argeo.security.UserAdminService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/** Deletes the selected roles */
-public class DeleteRole extends AbstractHandler {
-       private UserAdminService userAdminService;
-
-       @SuppressWarnings("unchecked")
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               return null;
-       }
-
-       public void setUserAdminService(UserAdminService userAdminService) {
-               this.userAdminService = userAdminService;
-       }
-}
-// ISelection selection = HandlerUtil.getCurrentSelection(event);
-// if (selection.isEmpty())
-// return null;
-//
-// List<String> toDelete = new ArrayList<String>();
-// Iterator<String> it = ((IStructuredSelection) selection).iterator();
-// while (it.hasNext()) {
-// toDelete.add(it.next());
-// }
-//
-// if (!MessageDialog
-// .openQuestion(
-// HandlerUtil.getActiveShell(event),
-// "Delete Role",
-// "Are you sure that you want to delete "
-// + toDelete
-// + "?\n"
-// + "This may lead to inconsistencies in the application."))
-// return null;
-//
-// for (String role : toDelete) {
-// userAdminService.deleteRole(role);
-// }
-//
-// JcrRolesView view = (JcrRolesView) HandlerUtil
-// .getActiveWorkbenchWindow(event).getActivePage()
-// .findView(JcrRolesView.ID);
-// view.refresh();
-// return null;
-// }
-//
-// public void setUserAdminService(UserAdminService userAdminService) {
-// this.userAdminService = userAdminService;
-// }
-// }
\ No newline at end of file
diff --git a/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/DeleteUser.java b/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/DeleteUser.java
deleted file mode 100644 (file)
index dbff6e5..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.admin.commands;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.ArgeoException;
-import org.argeo.jcr.ArgeoNames;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.security.UserAdminService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Deletes the selected user nodes */
-public class DeleteUser extends AbstractHandler {
-       private final static Log log = LogFactory.getLog(DeleteUser.class);
-
-       private UserAdminService userAdminService;
-
-       @SuppressWarnings("unchecked")
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               ISelection selection = HandlerUtil.getCurrentSelection(event);
-               if (selection.isEmpty())
-                       return null;
-
-               Map<String, Node> toDelete = new TreeMap<String, Node>();
-               Iterator<Node> it = ((IStructuredSelection) selection).iterator();
-               nodes: while (it.hasNext()) {
-                       Node profileNode = it.next();
-                       try {
-                               String userName = profileNode.getProperty(
-                                               ArgeoNames.ARGEO_USER_ID).getString();
-                               if (userName.equals(profileNode.getSession().getUserID())) {
-                                       log.warn("Cannot delete its own user: " + userName);
-                                       continue nodes;
-                               }
-                               toDelete.put(userName, profileNode);
-                       } catch (RepositoryException e) {
-                               log.warn("Cannot interpred user " + profileNode);
-                       }
-               }
-
-               if (!MessageDialog
-                               .openQuestion(
-                                               HandlerUtil.getActiveShell(event),
-                                               "Delete User",
-                                               "Are you sure that you want to delete users "
-                                                               + toDelete.keySet()
-                                                               + "?\n"
-                                                               + "This may lead to inconsistencies in the application."))
-                       return null;
-
-               for (String username : toDelete.keySet()) {
-                       Session session = null;
-                       try {
-                               Node profileNode = toDelete.get(username);
-                               userAdminService.deleteUser(username);
-                               profileNode.getParent().remove();
-                               session = profileNode.getSession();
-                               session.save();
-                       } catch (RepositoryException e) {
-                               JcrUtils.discardQuietly(session);
-                               throw new ArgeoException("Cannot list users", e);
-                       }
-               }
-
-               userAdminService.synchronize();
-               // JcrUsersView view = (JcrUsersView) HandlerUtil
-               // .getActiveWorkbenchWindow(event).getActivePage()
-               // .findView(JcrUsersView.ID);
-               // view.refresh();
-               return null;
-       }
-
-       public void setUserAdminService(UserAdminService userAdminService) {
-               this.userAdminService = userAdminService;
-       }
-}
\ No newline at end of file
diff --git a/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/DeleteUsers.java b/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/DeleteUsers.java
new file mode 100644 (file)
index 0000000..af2fb56
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.security.ui.admin.commands;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.argeo.security.ui.admin.SecurityAdminPlugin;
+import org.argeo.security.ui.admin.internal.UiAdminUtils;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.osgi.service.useradmin.User;
+
+/** Deletes the selected users */
+public class DeleteUsers extends AbstractHandler {
+       public final static String ID = SecurityAdminPlugin.PLUGIN_ID + ".deleteUsers";
+
+       @SuppressWarnings("unchecked")
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               ISelection selection = HandlerUtil.getCurrentSelection(event);
+               if (selection.isEmpty())
+                       return null;
+
+               Map<String, User> toDelete = new TreeMap<String, User>();
+               Iterator<User> it = ((IStructuredSelection) selection).iterator();
+               users: while (it.hasNext()) {
+                       User currUser = it.next();
+                       String userName = UiAdminUtils.getUsername(currUser);
+                       // check not deleting own user
+                       // if (userName.equals(profileNode.getSession().getUserID())) {
+                       // log.warn("Cannot delete its own user: " + userName);
+                       // continue nodes;
+                       // }
+                       toDelete.put(userName, currUser);
+               }
+
+               if (!MessageDialog
+                               .openQuestion(
+                                               HandlerUtil.getActiveShell(event),
+                                               "Delete Users",
+                                               "Are you sure that you want to delete users "
+                                                               + toDelete.keySet()
+                                                               + "?\n"
+                                                               + "This might lead to inconsistencies in the application."))
+                       return null;
+
+               for (String username : toDelete.keySet()) {
+                       // TODO perform real deletion
+               }
+               MessageDialog.openInformation(HandlerUtil.getActiveShell(event),
+                               "Unimplemented method",
+                               "The effective deletion is not yet implemented");
+               // TODO refresh?
+               // JcrUsersView view = (JcrUsersView) HandlerUtil
+               // .getActiveWorkbenchWindow(event).getActivePage()
+               // .findView(JcrUsersView.ID);
+               // view.refresh();
+               return null;
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/ForceRefresh.java b/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/ForceRefresh.java
new file mode 100644 (file)
index 0000000..189e785
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.security.ui.admin.commands;
+
+import org.argeo.security.ui.admin.views.GroupsView;
+import org.argeo.security.ui.admin.views.UsersView;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Retrieve the active view or editor and call forceRefresh method if defined */
+public class ForceRefresh extends AbstractHandler {
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               IWorkbenchWindow iww = HandlerUtil.getActiveWorkbenchWindow(event);
+               if (iww == null)
+                       return null;
+               IWorkbenchPage activePage = iww.getActivePage();
+               IWorkbenchPart part = activePage.getActivePart();
+               if (part instanceof UsersView)
+                       ((UsersView) part).refresh();
+               else if (part instanceof GroupsView)
+                       ((GroupsView) part).refresh();
+               return null;
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/NewGroup.java b/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/NewGroup.java
new file mode 100644 (file)
index 0000000..41672d5
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.security.ui.admin.commands;
+
+import org.argeo.security.ui.admin.SecurityAdminPlugin;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.osgi.service.useradmin.UserAdmin;
+
+/** Create a new group. */
+public class NewGroup extends AbstractHandler {
+       public final static String ID = SecurityAdminPlugin.PLUGIN_ID + ".newGroup";
+
+       private UserAdmin userAdmin;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               MessageDialog
+                               .openError(HandlerUtil.getActiveShell(event),
+                                               "Unimplemented method",
+                                               "Group creation is not yet implemented");
+               return null;
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setUserAdmin(UserAdmin userAdmin) {
+               this.userAdmin = userAdmin;
+       }
+}
+
+// JcrRolesView rolesView = (JcrRolesView) HandlerUtil
+// .getActiveWorkbenchWindow(event).getActivePage()
+// .findView(JcrRolesView.ID);
+// String role = rolesView.getNewRole();
+// if (role.trim().equals(""))
+// return null;
+// if (role.equals(rolesView.getAddNewRoleText()))
+// return null;
+// role = role.trim().toUpperCase();
+// if (!role.startsWith(rolePrefix))
+// role = rolePrefix + role;
+// if (userAdminService.listEditableRoles().contains(role))
+// throw new ArgeoException("Role " + role + " already exists");
+// userAdminService.newRole(role);
+// rolesView.refresh();
+//
+// // refresh editors
+// IEditorReference[] refs = HandlerUtil.getActiveWorkbenchWindow(event)
+// .getActivePage()
+// .findEditors(null, JcrArgeoUserEditor.ID, IWorkbenchPage.MATCH_ID);
+// for (IEditorReference ref : refs) {
+// JcrArgeoUserEditor userEditor = (JcrArgeoUserEditor) ref.getEditor(false);
+// if (userEditor != null) {
+// userEditor.refresh();
+// }
+// }
+// return null;
+// }
+//
+// public void setUserAdminService(UserAdminService userAdminService) {
+// this.userAdminService = userAdminService;
+// }
+//
+// }
index 235e4d7e9d084bb0b9370eb8e1ba47eaba5803c8..fce684a67c965cb1430c987c65594391d08fd961 100644 (file)
@@ -80,10 +80,6 @@ public class NewUser extends AbstractHandler {
                        ((UsersView) part).refresh();
        }
 
-       public void setUserAdmin(UserAdmin userAdmin) {
-               this.userAdmin = userAdmin;
-       }
-
        private class NewUserWizard extends Wizard {
 
                // pages
@@ -100,8 +96,8 @@ public class NewUser extends AbstractHandler {
                public void addPages() {
                        mainUserInfo = new MainUserInfoWizardPage();
                        addPage(mainUserInfo);
-                       String message = "Dummy wizard to ease user creation tests: mail, last name are automatically "
-                                       + "generated form the uid, password are defauted to 'demo'.";
+                       String message = "Dummy wizard to ease user creation tests:\n Mail and last name are automatically "
+                                       + "generated form the uid. Password are defauted to 'demo'.";
                        mainUserInfo.setMessage(message, WizardPage.WARNING);
                }
 
@@ -254,7 +250,9 @@ public class NewUser extends AbstractHandler {
 
                }
        }
-
-       // Local helpers
-
+       
+       /* DEPENDENCY INJECTION */
+       public void setUserAdmin(UserAdmin userAdmin) {
+               this.userAdmin = userAdmin;
+       }
 }
\ No newline at end of file
diff --git a/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/OpenArgeoUserEditor.java b/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/OpenArgeoUserEditor.java
deleted file mode 100644 (file)
index 3dd1a7d..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.admin.commands;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/** Command handler to set visible or open a Argeo user. */
-public class OpenArgeoUserEditor extends AbstractHandler {
-       public final static String COMMAND_ID = "org.argeo.security.ui.admin.openArgeoUserEditor";
-       public final static String PARAM_USERNAME = "org.argeo.security.ui.admin.username";
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               // try {
-               // ArgeoUserEditorInput editorInput = new ArgeoUserEditorInput(
-               // event.getParameter(PARAM_USERNAME));
-               // IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(
-               // event).getActivePage();
-               // activePage.openEditor(editorInput, JcrArgeoUserEditor.ID);
-               // } catch (Exception e) {
-               // throw new ExecutionException("Cannot open editor", e);
-               // }
-               return null;
-       }
-}
diff --git a/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/RefreshRoles.java b/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/RefreshRoles.java
deleted file mode 100644 (file)
index 41c78f0..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.admin.commands;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/**
- * Refreshes the roles view.
- */
-public class RefreshRoles extends AbstractHandler {
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-
-               return null;
-       }
-
-}
\ No newline at end of file
diff --git a/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/RefreshUsersList.java b/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/RefreshUsersList.java
deleted file mode 100644 (file)
index e6be8d9..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.admin.commands;
-
-import javax.jcr.Repository;
-
-import org.argeo.security.UserAdminService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/**
- * Refreshes the main user list, removing nodes which are not referenced by user
- * admin service.
- */
-public class RefreshUsersList extends AbstractHandler {
-       private UserAdminService userAdminService;
-       private Repository repository;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               // Set<String> users = userAdminService.listUsers();
-               // Session session = null;
-               // try {
-               // session = repository.login();
-               // Query query = session
-               // .getWorkspace()
-               // .getQueryManager()
-               // .createQuery(
-               // "select * from [" + ArgeoTypes.ARGEO_USER_HOME
-               // + "]", Query.JCR_SQL2);
-               // NodeIterator nit = query.execute().getNodes();
-               // while (nit.hasNext()) {
-               // Node node = nit.nextNode();
-               // String username = node.getProperty(ArgeoNames.ARGEO_USER_ID)
-               // .getString();
-               // if (!users.contains(username))
-               // node.remove();
-               // }
-               // session.save();
-               // } catch (RepositoryException e) {
-               // JcrUtils.discardQuietly(session);
-               // throw new ArgeoException("Cannot list users", e);
-               // } finally {
-               // JcrUtils.logoutQuietly(session);
-               // }
-               // userAdminService.synchronize();
-               //
-               // // FIXME try to refresh views that extend the JcrUsersView and have
-               // another
-               // // ID
-               // IWorkbenchPart part = HandlerUtil.getActiveWorkbenchWindow(event)
-               // .getActivePage().getActivePart();
-               // if (part instanceof JcrUsersView)
-               // ((JcrUsersView) part).refresh();
-               //
-               // // Try to refresh JcrUsersView if opened
-               // JcrUsersView view = (JcrUsersView) HandlerUtil
-               // .getActiveWorkbenchWindow(event).getActivePage()
-               // .findView(JcrUsersView.ID);
-               // if (view != null)
-               // view.refresh();
-
-               return null;
-       }
-
-       public void setUserAdminService(UserAdminService userAdminService) {
-               this.userAdminService = userAdminService;
-       }
-
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-
-}
\ No newline at end of file
index bd16f8bcf4a16524e147354959bff034d05366c1..a2047bf6a745e4200027ec47b0d4fc8fbd56a561 100644 (file)
@@ -15,6 +15,7 @@
  */
 package org.argeo.security.ui.admin.commands;
 
+import org.argeo.security.ui.admin.SecurityAdminPlugin;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
@@ -26,7 +27,8 @@ import org.eclipse.ui.handlers.HandlerUtil;
 
 /** Save the currently edited Argeo user. */
 public class SaveArgeoUser extends AbstractHandler {
-       public final static String COMMAND_ID = "org.argeo.security.ui.admin.saveArgeoUser";
+       public final static String ID = SecurityAdminPlugin.PLUGIN_ID
+                       + ".saveArgeoUser";
 
        public Object execute(ExecutionEvent event) throws ExecutionException {
                try {
@@ -43,5 +45,4 @@ public class SaveArgeoUser extends AbstractHandler {
                }
                return null;
        }
-
-}
+}
\ No newline at end of file
index 3b8b352ecfff18d77ada4a0831d6cf366524189d..d38a565f5ecff96c5ef8a9045c22bb5bab55b32d 100644 (file)
  */
 package org.argeo.security.ui.admin.commands;
 
-import javax.jcr.Repository;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.security.UserAdminService;
-import org.argeo.security.ui.admin.wizards.UserBatchUpdateWizard;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
 
 /** Launch a wizard to update various properties about users in JCR. */
 public class UserBatchUpdate extends AbstractHandler {
-       private Repository repository;
-       private UserAdminService userAdminService;
+       // private Repository repository;
+       // private UserAdminService userAdminService;
 
        public Object execute(ExecutionEvent event) throws ExecutionException {
-               Session session = null;
-               try {
-                       session = repository.login();
-                       UserBatchUpdateWizard userBatchUpdateWizard = new UserBatchUpdateWizard(
-                                       session, userAdminService);
-                       WizardDialog dialog = new WizardDialog(
-                                       HandlerUtil.getActiveShell(event), userBatchUpdateWizard);
-                       dialog.open();
-               } catch (Exception e) {
-                       throw new ExecutionException("Cannot open wizard", e);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-               }
+               // Session session = null;
+               // try {
+               // session = repository.login();
+               // UserBatchUpdateWizard userBatchUpdateWizard = new
+               // UserBatchUpdateWizard(
+               // session, userAdminService);
+               // WizardDialog dialog = new WizardDialog(
+               // HandlerUtil.getActiveShell(event), userBatchUpdateWizard);
+               // dialog.open();
+               // } catch (Exception e) {
+               // throw new ExecutionException("Cannot open wizard", e);
+               // } finally {
+               // JcrUtils.logoutQuietly(session);
+               // }
                return null;
        }
 
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-
-       public void setUserAdminService(UserAdminService userAdminService) {
-               this.userAdminService = userAdminService;
-       }
+//     public void setRepository(Repository repository) {
+//             this.repository = repository;
+//     }
+       //
+       // public void setUserAdminService(UserAdminService userAdminService) {
+       // this.userAdminService = userAdminService;
+       // }
 
        // public void setJcrSecurityModel(JcrSecurityModel jcrSecurityModel) {
        // this.jcrSecurityModel = jcrSecurityModel;
index b3bb32df8cb81a57eef13b6e80d383e0cff9f0a7..811860aba1a9e1a64c1d511e8b2eeac5901df425 100644 (file)
@@ -42,9 +42,7 @@ import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.ScrolledForm;
 import org.eclipse.ui.forms.widgets.Section;
 
-/**
- * Display/edit the properties common to all Argeo users
- */
+/** Display/edit the properties common to all Argeo users */
 public class DefaultUserMainPage extends FormPage implements ArgeoNames {
        final static String ID = "argeoUserEditor.mainPage";
 
diff --git a/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/editors/JcrArgeoUserEditor.java b/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/editors/JcrArgeoUserEditor.java
deleted file mode 100644 (file)
index e63dfc5..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.admin.editors;
-
-public class JcrArgeoUserEditor{}
-/** Editor for an Argeo user. Legacy. TODO Remove*/
-// public class JcrArgeoUserEditor extends FormEditor {
-// private static final long serialVersionUID = 1933296330339252869L;
-//
-// public final static String ID = SecurityAdminPlugin.PLUGIN_ID
-// + ".adminArgeoUserEditor";
-//
-// /* DEPENDENCY INJECTION */
-// private Session session;
-// private UserAdminService userAdminService;
-//
-// // private Node userHome;
-// private Node userProfile;
-// private JcrUserDetails userDetails;
-//
-// public void init(IEditorSite site, IEditorInput input)
-// throws PartInitException {
-// super.init(site, input);
-// String username = ((ArgeoUserEditorInput) getEditorInput())
-// .getUsername();
-// userProfile = UserJcrUtils.getUserProfile(session, username);
-//
-// if (userAdminService.userExists(username)) {
-// try {
-// userDetails = (JcrUserDetails) userAdminService
-// .loadUserByUsername(username);
-// } catch (Exception e) {
-// throw new ArgeoException("Cannot retrieve userDetails for "
-// + username, e);
-// }
-// } else {
-// try {
-// userDetails = new JcrUserDetails(session, username, null,
-// new ArrayList<GrantedAuthority>());
-// } catch (RepositoryException e) {
-// throw new ArgeoException("Cannot retrieve disabled JCR profile");
-// }
-// }
-//
-// this.setPartProperty("name", username != null ? username : "<new user>");
-// setPartName(username != null ? username : "<new user>");
-// }
-//
-// protected void addPages() {
-// try {
-// addPage(new DefaultUserMainPage(this, userProfile));
-// addPage(new UserRolesPage(this, userDetails, userAdminService));
-// } catch (Exception e) {
-// throw new ArgeoException("Cannot add pages", e);
-// }
-// }
-//
-// @Override
-// public void doSave(IProgressMonitor monitor) {
-// // list pages
-// // TODO: make it more generic
-// DefaultUserMainPage defaultUserMainPage = (DefaultUserMainPage)
-// findPage(DefaultUserMainPage.ID);
-// if (defaultUserMainPage.isDirty()) {
-// defaultUserMainPage.doSave(monitor);
-// String newPassword = defaultUserMainPage.getNewPassword();
-// defaultUserMainPage.resetNewPassword();
-// if (newPassword != null)
-// userDetails = userDetails.cloneWithNewPassword(newPassword);
-// }
-//
-// UserRolesPage userRolesPage = (UserRolesPage) findPage(UserRolesPage.ID);
-// if (userRolesPage.isDirty()) {
-// userRolesPage.doSave(monitor);
-// userDetails = userDetails.cloneWithNewRoles(userRolesPage
-// .getRoles());
-// }
-//
-// userAdminService.updateUser(userDetails);
-//
-// // if (userAdminService.userExists(user.getUsername()))
-// // userAdminService.updateUser(user);
-// // else {
-// // userAdminService.newUser(user);
-// // setPartName(user.getUsername());
-// // }
-// firePropertyChange(PROP_DIRTY);
-//
-// userRolesPage.setUserDetails(userDetails);
-//
-// // FIXME rather use a refresh command. Fails when called by another
-// // view.
-// // refresh users view
-// IWorkbench iw = SecurityAdminPlugin.getDefault().getWorkbench();
-// JcrUsersView usersView = (JcrUsersView) iw.getActiveWorkbenchWindow()
-// .getActivePage().findView(JcrUsersView.ID);
-// if (usersView != null)
-// usersView.refresh();
-// }
-//
-//
-//
-// @Override
-// public void doSaveAs() {
-// }
-//
-// @Override
-// public boolean isSaveAsAllowed() {
-// return false;
-// }
-//
-// public void refresh() {
-// UserRolesPage userRolesPage = (UserRolesPage) findPage(UserRolesPage.ID);
-// userRolesPage.refresh();
-// }
-//
-// @Override
-// public void dispose() {
-// JcrUtils.logoutQuietly(session);
-// super.dispose();
-// }
-//
-// /* DEPENDENCY INJECTION */
-// public void setUserAdminService(UserAdminService userAdminService) {
-// this.userAdminService = userAdminService;
-// }
-//
-// public void setRepository(Repository repository) {
-// try {
-// session = repository.login();
-// } catch (RepositoryException re) {
-// throw new ArgeoException("Unable to initialise local session", re);
-// }
-// }
-// }
index a5879b9f95540bd8ab153a5dc6758706c4e8f5de..761f48b80f0d4292f3858f85fe1cffaad6245090 100644 (file)
@@ -89,12 +89,10 @@ public class UserEditor extends FormEditor implements UserAdminConstants {
 
        protected void addPages() {
                try {
-
                        if (user.getType() == Role.GROUP)
                                addPage(new GroupMainPage(this, userAdmin));
                        else
                                addPage(new UserMainPage(this, userAdmin));
-
                } catch (Exception e) {
                        throw new ArgeoException("Cannot add pages", e);
                }
index 1cd9c0e3a5f7da528e35a4d0b4dd833651b7c337..05858cbd4e4b290a74a0afb5821137e4e734a2de 100644 (file)
@@ -6,6 +6,9 @@ import java.security.Principal;
 import javax.security.auth.Subject;
 import javax.security.auth.x500.X500Principal;
 
+import org.osgi.service.useradmin.Role;
+import org.osgi.service.useradmin.User;
+
 /** First effort to centralize back end methods used by the user admin UI */
 public class UiAdminUtils {
        public final static String getUsername() {
@@ -16,6 +19,21 @@ public class UiAdminUtils {
 
        }
 
+       public final static String getUsername(User user) {
+               String cn = getProperty(user, UserAdminConstants.KEY_CN);
+               if (isEmpty(cn))
+                       cn = getProperty(user, UserAdminConstants.KEY_UID);
+               return cn;
+       }
+
+       public final static String getProperty(Role role, String key) {
+               Object obj = role.getProperties().get(key);
+               if (obj != null)
+                       return (String) obj;
+               else
+                       return "";
+       }
+
        public final static String getDefaultCn(String firstName, String lastName) {
                return (firstName.trim() + " " + lastName.trim() + " ").trim();
        }
@@ -31,4 +49,11 @@ public class UiAdminUtils {
                        return !"".equals(string.trim());
        }
 
+       public final static boolean isEmpty(String string) {
+               if (string == null)
+                       return true;
+               else
+                       return "".equals(string.trim());
+       }
+
 }
\ No newline at end of file
index dd9456c8c2d2b58d95d1a4e2e60e178c5b9f7707..1ee26a2ab160ab03e94ae0750030dadfe8953697 100644 (file)
@@ -44,7 +44,7 @@ public class GroupsView extends UsersView implements ArgeoNames {
        private UserAdmin userAdmin;
 
        // UI Objects
-       private UserTableViewer userTableViewerCmp;
+       private UserTableViewer groupTableViewerCmp;
        private TableViewer userViewer;
        private List<ColumnDefinition> columnDefs = new ArrayList<ColumnDefinition>();
 
@@ -58,20 +58,20 @@ public class GroupsView extends UsersView implements ArgeoNames {
                                "Distinguished Name", 300));
                
                // Create and configure the table
-               userTableViewerCmp = new MyUserTableViewer(parent, SWT.MULTI
+               groupTableViewerCmp = new MyUserTableViewer(parent, SWT.MULTI
                                | SWT.H_SCROLL | SWT.V_SCROLL, userAdmin);
 
-               userTableViewerCmp.setColumnDefinitions(columnDefs);
-               userTableViewerCmp.populate(true, false);
-               userTableViewerCmp.setLayoutData(EclipseUiUtils.fillAll());
+               groupTableViewerCmp.setColumnDefinitions(columnDefs);
+               groupTableViewerCmp.populate(true, false);
+               groupTableViewerCmp.setLayoutData(EclipseUiUtils.fillAll());
 
                // Links
-               userViewer = userTableViewerCmp.getTableViewer();
+               userViewer = groupTableViewerCmp.getTableViewer();
                userViewer.addDoubleClickListener(new UserTableDefaultDClickListener());
                getViewSite().setSelectionProvider(userViewer);
 
                // Really?
-               userTableViewerCmp.refresh();
+               groupTableViewerCmp.refresh();
        }
 
        private class MyUserTableViewer extends UserTableViewer {
@@ -99,6 +99,11 @@ public class GroupsView extends UsersView implements ArgeoNames {
                }
        }
 
+       public void refresh() {
+               groupTableViewerCmp.refresh();
+       }
+
+       
        // Override generic view methods
        @Override
        public void dispose() {
@@ -107,7 +112,7 @@ public class GroupsView extends UsersView implements ArgeoNames {
 
        @Override
        public void setFocus() {
-               userTableViewerCmp.setFocus();
+               groupTableViewerCmp.setFocus();
        }
 
        /* DEPENDENCY INJECTION */