1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.slc.client.ui.dist.commands;
17
18 import javax.jcr.Repository;
19 import javax.jcr.RepositoryException;
20 import javax.jcr.Session;
21
22 import org.argeo.jcr.JcrUtils;
23 import org.argeo.slc.SlcException;
24 import org.argeo.slc.client.ui.dist.DistPlugin;
25 import org.argeo.slc.client.ui.dist.wizards.ChangeRightsWizard;
26 import org.eclipse.core.commands.AbstractHandler;
27 import org.eclipse.core.commands.ExecutionEvent;
28 import org.eclipse.core.commands.ExecutionException;
29 import org.eclipse.jface.resource.ImageDescriptor;
30 import org.eclipse.jface.wizard.WizardDialog;
31 import org.eclipse.ui.handlers.HandlerUtil;
32
33
34 public class ManageWorkspaceAuth extends AbstractHandler {
35
36
37 public final static String ID = DistPlugin.PLUGIN_ID
38 + ".manageWorkspaceAuth";
39 public final static String DEFAULT_LABEL = "Manage Rights";
40 public final static ImageDescriptor DEFAULT_ICON = DistPlugin
41 .getImageDescriptor("icons/changeRights.gif");
42
43 public final static String PARAM_WORKSPACE_NAME = DistPlugin.PLUGIN_ID
44 + ".workspaceName";
45
46
47 private Repository repository;
48 private Session session;
49
50 public Object execute(ExecutionEvent event) throws ExecutionException {
51 String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
52 try {
53 session = repository.login(workspaceName);
54 ChangeRightsWizard wizard = new ChangeRightsWizard(session);
55 WizardDialog dialog = new WizardDialog(
56 HandlerUtil.getActiveShell(event), wizard);
57 dialog.open();
58 return null;
59 } catch (RepositoryException re) {
60 throw new SlcException("Cannot log in the repository "
61 + repository + " in workspace " + workspaceName, re);
62 } finally {
63 JcrUtils.logoutQuietly(session);
64 }
65 }
66
67
68 public void setRepository(Repository repository) {
69 this.repository = repository;
70 }
71 }