]> git.argeo.org Git - gpl/argeo-slc.git/blob - cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/ManageWorkspaceAuth.java
Adapt to changes in Argeo Commons.
[gpl/argeo-slc.git] / cms / org.argeo.slc.client.ui.dist / src / org / argeo / slc / client / ui / dist / commands / ManageWorkspaceAuth.java
1 package org.argeo.slc.client.ui.dist.commands;
2
3 import javax.jcr.Repository;
4 import javax.jcr.RepositoryException;
5 import javax.jcr.Session;
6
7 import org.argeo.jcr.JcrUtils;
8 import org.argeo.slc.SlcException;
9 import org.argeo.slc.client.ui.dist.DistPlugin;
10 import org.argeo.slc.client.ui.dist.wizards.ChangeRightsWizard;
11 import org.eclipse.core.commands.AbstractHandler;
12 import org.eclipse.core.commands.ExecutionEvent;
13 import org.eclipse.core.commands.ExecutionException;
14 import org.eclipse.jface.resource.ImageDescriptor;
15 import org.eclipse.jface.wizard.WizardDialog;
16 import org.eclipse.ui.handlers.HandlerUtil;
17
18 /** Open a dialog to manage rights on the current workspace's root node */
19 public class ManageWorkspaceAuth extends AbstractHandler {
20 // private static final Log log =
21 // LogFactory.getLog(ManageWorkspaceAuth.class);
22 public final static String ID = DistPlugin.PLUGIN_ID
23 + ".manageWorkspaceAuth";
24 public final static String DEFAULT_LABEL = "Manage Rights";
25 public final static ImageDescriptor DEFAULT_ICON = DistPlugin
26 .getImageDescriptor("icons/changeRights.gif");
27
28 public final static String PARAM_WORKSPACE_NAME = DistPlugin.PLUGIN_ID
29 + ".workspaceName";
30
31 /* DEPENDENCY INJECTION */
32 private Repository repository;
33 private Session session;
34
35 public Object execute(ExecutionEvent event) throws ExecutionException {
36 String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
37 try {
38 session = repository.login(workspaceName);
39 ChangeRightsWizard wizard = new ChangeRightsWizard(session);
40 WizardDialog dialog = new WizardDialog(
41 HandlerUtil.getActiveShell(event), wizard);
42 dialog.open();
43 return null;
44 } catch (RepositoryException re) {
45 throw new SlcException("Cannot log in the repository "
46 + repository + " in workspace " + workspaceName, re);
47 } finally {
48 JcrUtils.logoutQuietly(session);
49 }
50 }
51
52 /* DEPENDENCY INJECTION */
53 public void setRepository(Repository repository) {
54 this.repository = repository;
55 }
56 }