]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/DeleteUsers.java
2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.security
.ui
.admin
.commands
;
18 import java
.util
.Iterator
;
20 import java
.util
.TreeMap
;
22 import org
.argeo
.security
.ui
.admin
.SecurityAdminPlugin
;
23 import org
.argeo
.security
.ui
.admin
.internal
.UiAdminUtils
;
24 import org
.eclipse
.core
.commands
.AbstractHandler
;
25 import org
.eclipse
.core
.commands
.ExecutionEvent
;
26 import org
.eclipse
.core
.commands
.ExecutionException
;
27 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
28 import org
.eclipse
.jface
.viewers
.ISelection
;
29 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
30 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
31 import org
.osgi
.service
.useradmin
.User
;
33 /** Deletes the selected users */
34 public class DeleteUsers
extends AbstractHandler
{
35 public final static String ID
= SecurityAdminPlugin
.PLUGIN_ID
+ ".deleteUsers";
37 @SuppressWarnings("unchecked")
38 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
39 ISelection selection
= HandlerUtil
.getCurrentSelection(event
);
40 if (selection
.isEmpty())
43 Map
<String
, User
> toDelete
= new TreeMap
<String
, User
>();
44 Iterator
<User
> it
= ((IStructuredSelection
) selection
).iterator();
45 users
: while (it
.hasNext()) {
46 User currUser
= it
.next();
47 String userName
= UiAdminUtils
.getUsername(currUser
);
48 // check not deleting own user
49 // if (userName.equals(profileNode.getSession().getUserID())) {
50 // log.warn("Cannot delete its own user: " + userName);
53 toDelete
.put(userName
, currUser
);
58 HandlerUtil
.getActiveShell(event
),
60 "Are you sure that you want to delete users "
63 + "This might lead to inconsistencies in the application."))
66 for (String username
: toDelete
.keySet()) {
67 // TODO perform real deletion
69 MessageDialog
.openInformation(HandlerUtil
.getActiveShell(event
),
70 "Unimplemented method",
71 "The effective deletion is not yet implemented");
73 // JcrUsersView view = (JcrUsersView) HandlerUtil
74 // .getActiveWorkbenchWindow(event).getActivePage()
75 // .findView(JcrUsersView.ID);