]> git.argeo.org Git - gpl/argeo-slc.git/blob - eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/ManageWorkspaceAuth.java
09ece2f5c0acfa62bd68656529d9d83f2ab9cafa
[gpl/argeo-slc.git] / eclipse / 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 import javax.jcr.security.Privilege;
7
8 import org.argeo.ArgeoException;
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.wizard.WizardDialog;
15 import org.eclipse.ui.handlers.HandlerUtil;
16
17 /**
18 * Open a dialog to change rights on the root node of the current workspace.
19 */
20
21 public class ManageWorkspaceAuth extends AbstractHandler {
22 // private static final Log log =
23 // LogFactory.getLog(ManageWorkspaceAuth.class);
24 public final static String ID = DistPlugin.ID + ".manageWorkspaceAuth";
25 public final static String PARAM_WORKSPACE_NAME = DistPlugin.ID
26 + ".workspaceName";
27 public final static String DEFAULT_LABEL = "Change rights for current workspace";
28 public final static String DEFAULT_ICON_PATH = "icons/changeRights.gif";
29
30 /* DEPENDENCY INJECTION */
31 private Repository repository;
32
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 ArgeoException(
46 "Unexpected error while creating the new workspace.", re);
47 } finally {
48 if (session != null)
49 session.logout();
50 }
51 }
52
53 /* DEPENDENCY INJECTION */
54 public void setRepository(Repository repository) {
55 this.repository = repository;
56 }
57 }