View Javadoc
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.wizards;
17  
18  import javax.jcr.RepositoryException;
19  import javax.jcr.Session;
20  
21  import org.argeo.jcr.JcrUtils;
22  import org.argeo.slc.SlcException;
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  
33  	// This page widget
34  	private ChooseRightsPage page;
35  
36  	public ChangeRightsWizard(Session currentSession) {
37  		super();
38  		this.currentSession = currentSession;
39  	}
40  
41  	@Override
42  	public void addPages() {
43  		try {
44  			page = new ChooseRightsPage();
45  			addPage(page);
46  		} catch (Exception e) {
47  			throw new SlcException("Cannot add page to wizard ", e);
48  		}
49  	}
50  
51  	@Override
52  	public boolean performFinish() {
53  		if (!canFinish())
54  			return false;
55  		try {
56  			JcrUtils.addPrivilege(currentSession, "/", page.getGroupName(),
57  					page.getAuthTypeStr());
58  		} catch (RepositoryException re) {
59  			throw new SlcException(
60  					"Unexpected error while setting privileges", re);
61  		}
62  		return true;
63  	}
64  }