]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/RefreshUsersList.java
Work on user and group editors. Comment out legacy code that use old userAdminService
[lgpl/argeo-commons.git] / org.argeo.security.ui.admin / src / org / argeo / security / ui / admin / commands / RefreshUsersList.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16 package org.argeo.security.ui.admin.commands;
17
18 import javax.jcr.Repository;
19
20 import org.argeo.security.UserAdminService;
21 import org.eclipse.core.commands.AbstractHandler;
22 import org.eclipse.core.commands.ExecutionEvent;
23 import org.eclipse.core.commands.ExecutionException;
24
25 /**
26 * Refreshes the main user list, removing nodes which are not referenced by user
27 * admin service.
28 */
29 public class RefreshUsersList extends AbstractHandler {
30 private UserAdminService userAdminService;
31 private Repository repository;
32
33 public Object execute(ExecutionEvent event) throws ExecutionException {
34 // Set<String> users = userAdminService.listUsers();
35 // Session session = null;
36 // try {
37 // session = repository.login();
38 // Query query = session
39 // .getWorkspace()
40 // .getQueryManager()
41 // .createQuery(
42 // "select * from [" + ArgeoTypes.ARGEO_USER_HOME
43 // + "]", Query.JCR_SQL2);
44 // NodeIterator nit = query.execute().getNodes();
45 // while (nit.hasNext()) {
46 // Node node = nit.nextNode();
47 // String username = node.getProperty(ArgeoNames.ARGEO_USER_ID)
48 // .getString();
49 // if (!users.contains(username))
50 // node.remove();
51 // }
52 // session.save();
53 // } catch (RepositoryException e) {
54 // JcrUtils.discardQuietly(session);
55 // throw new ArgeoException("Cannot list users", e);
56 // } finally {
57 // JcrUtils.logoutQuietly(session);
58 // }
59 // userAdminService.synchronize();
60 //
61 // // FIXME try to refresh views that extend the JcrUsersView and have
62 // another
63 // // ID
64 // IWorkbenchPart part = HandlerUtil.getActiveWorkbenchWindow(event)
65 // .getActivePage().getActivePart();
66 // if (part instanceof JcrUsersView)
67 // ((JcrUsersView) part).refresh();
68 //
69 // // Try to refresh JcrUsersView if opened
70 // JcrUsersView view = (JcrUsersView) HandlerUtil
71 // .getActiveWorkbenchWindow(event).getActivePage()
72 // .findView(JcrUsersView.ID);
73 // if (view != null)
74 // view.refresh();
75
76 return null;
77 }
78
79 public void setUserAdminService(UserAdminService userAdminService) {
80 this.userAdminService = userAdminService;
81 }
82
83 public void setRepository(Repository repository) {
84 this.repository = repository;
85 }
86
87 }