]> 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
Fix file download for rap. Add various links in the bundle detail editor.
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui.dist / src / main / java / org / argeo / slc / client / ui / dist / commands / ManageWorkspaceAuth.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.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.ArgeoException;
23 import org.argeo.jcr.JcrUtils;
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 * Open a dialog to manage rights on the current workspace's root node.
35 */
36 public class ManageWorkspaceAuth extends AbstractHandler {
37 // private static final Log log =
38 // LogFactory.getLog(ManageWorkspaceAuth.class);
39 public final static String ID = DistPlugin.ID + ".manageWorkspaceAuth";
40 public final static String DEFAULT_LABEL = "Manage Rights";
41 public final static ImageDescriptor DEFAULT_ICON = DistPlugin
42 .getImageDescriptor("icons/changeRights.gif");
43
44 public final static String PARAM_WORKSPACE_NAME = DistPlugin.ID
45 + ".workspaceName";
46
47 /* DEPENDENCY INJECTION */
48 private Repository repository;
49 private Session session;
50
51 public Object execute(ExecutionEvent event) throws ExecutionException {
52 String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
53 try {
54 session = repository.login(workspaceName);
55 ChangeRightsWizard wizard = new ChangeRightsWizard(session);
56 WizardDialog dialog = new WizardDialog(
57 HandlerUtil.getActiveShell(event), wizard);
58 dialog.open();
59 return null;
60 } catch (RepositoryException re) {
61 throw new ArgeoException("Cannot log in the repository "
62 + repository + " in workspace " + workspaceName, re);
63 } finally {
64 JcrUtils.logoutQuietly(session);
65 }
66 }
67
68 /* DEPENDENCY INJECTION */
69 public void setRepository(Repository repository) {
70 this.repository = repository;
71 }
72 }