]> git.argeo.org Git - gpl/argeo-slc.git/blob - plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/ManageWorkspaceAuth.java
Improve UI dist
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui.dist / src / main / java / 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.ArgeoException;
8 import org.argeo.slc.client.ui.dist.DistPlugin;
9 import org.argeo.slc.client.ui.dist.wizards.ChangeRightsWizard;
10 import org.eclipse.core.commands.AbstractHandler;
11 import org.eclipse.core.commands.ExecutionEvent;
12 import org.eclipse.core.commands.ExecutionException;
13 import org.eclipse.jface.wizard.WizardDialog;
14 import org.eclipse.ui.handlers.HandlerUtil;
15
16 /**
17 * Open a dialog to change rights on the root node of the current workspace.
18 */
19
20 public class ManageWorkspaceAuth extends AbstractHandler {
21 // private static final Log log =
22 // LogFactory.getLog(ManageWorkspaceAuth.class);
23 public final static String ID = DistPlugin.ID + ".manageWorkspaceAuth";
24 public final static String PARAM_WORKSPACE_NAME = DistPlugin.ID
25 + ".workspaceName";
26 public final static String DEFAULT_LABEL = "Manage Rights";
27 public final static String DEFAULT_ICON_PATH = "icons/changeRights.gif";
28
29 /* DEPENDENCY INJECTION */
30 private Repository repository;
31
32 private Session session;
33
34 public Object execute(ExecutionEvent event) throws ExecutionException {
35 String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
36 try {
37 session = repository.login(workspaceName);
38 ChangeRightsWizard wizard = new ChangeRightsWizard(session);
39 WizardDialog dialog = new WizardDialog(
40 HandlerUtil.getActiveShell(event), wizard);
41 dialog.open();
42 return null;
43 } catch (RepositoryException re) {
44 throw new ArgeoException(
45 "Unexpected error while creating the new workspace.", re);
46 } finally {
47 if (session != null)
48 session.logout();
49 }
50 }
51
52 /* DEPENDENCY INJECTION */
53 public void setRepository(Repository repository) {
54 this.repository = repository;
55 }
56 }