]> git.argeo.org Git - lgpl/argeo-commons.git/blob - server/plugins/org.argeo.jcr.ui.explorer/src/main/java/org/argeo/jcr/ui/explorer/wizards/ChangeRightsWizard.java
AddWorkspace and AddPrivileges in JCR Explorer
[lgpl/argeo-commons.git] / server / plugins / org.argeo.jcr.ui.explorer / src / main / java / org / argeo / jcr / ui / explorer / wizards / ChangeRightsWizard.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.jcr.ui.explorer.wizards;
17
18 import javax.jcr.RepositoryException;
19 import javax.jcr.Session;
20
21 import org.argeo.ArgeoException;
22 import org.argeo.jcr.JcrUtils;
23 import org.eclipse.jface.wizard.Wizard;
24
25 /**
26 * Small wizard to manage authorizations on the root node of the current
27 * workspace
28 */
29 public class ChangeRightsWizard extends Wizard {
30
31 private Session currentSession;
32 private String path;
33
34 // This page widget
35 private ChooseRightsPage page;
36
37 public ChangeRightsWizard(Session currentSession, String path) {
38 super();
39 this.currentSession = currentSession;
40 this.path = path;
41 }
42
43 @Override
44 public void addPages() {
45 try {
46 page = new ChooseRightsPage(path);
47 addPage(page);
48 } catch (Exception e) {
49 throw new ArgeoException("Cannot add page to wizard ", e);
50 }
51 }
52
53 @Override
54 public boolean performFinish() {
55 if (!canFinish())
56 return false;
57 try {
58 JcrUtils.addPrivilege(currentSession, path, page.getGroupName(),
59 page.getAuthTypeStr());
60 } catch (RepositoryException re) {
61 throw new ArgeoException(
62 "Unexpected error while setting privileges", re);
63 }
64 return true;
65 }
66 }