Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
RenameRoleCommand |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright (c) 2009, Swiss Federal Department of Defence Civil Protection and Sport | |
3 | * (http://www.vbs.admin.ch) | |
4 | * Copyright (c) 2009, Ergon Informatik AG (http://www.ergon.ch) | |
5 | * All rights reserved. | |
6 | * | |
7 | * Licensed under the Open Permis License which accompanies this distribution, | |
8 | * and is available at http://www.openpermis.org/BSDlicenceKent.txt | |
9 | */ | |
10 | package org.openpermis.editor.policy.command; | |
11 | ||
12 | import org.openpermis.policy.bean.PolicyBean; | |
13 | import org.openpermis.policy.bean.RoleHierarchyBean; | |
14 | ||
15 | ||
16 | /** | |
17 | * Renames a role. | |
18 | * @since 0.3.0 | |
19 | */ | |
20 | public class RenameRoleCommand extends AbstractRoleCommand { | |
21 | ||
22 | //---- State | |
23 | ||
24 | /** | |
25 | * @since 0.3.0 | |
26 | */ | |
27 | private final String newName; | |
28 | ||
29 | //---- Constructors | |
30 | ||
31 | /** | |
32 | * Creates a {@link RenameRoleCommand}. | |
33 | * @since 0.3.0 | |
34 | */ | |
35 | public RenameRoleCommand ( | |
36 | String name, | |
37 | String roleName, | |
38 | String newName, | |
39 | RoleHierarchyBean roleHierarchyBean) { | |
40 | ||
41 | 0 | super( |
42 | name, | |
43 | roleName, | |
44 | roleHierarchyBean | |
45 | ); | |
46 | ||
47 | 0 | this.newName = newName; |
48 | 0 | } |
49 | ||
50 | //---- AbstractHierarchyCommand | |
51 | ||
52 | /** | |
53 | * @since 0.3.0 | |
54 | */ | |
55 | @Override | |
56 | public void execute (PolicyBean policy) throws Exception { | |
57 | 0 | getRoleHierarchyBean().renameRole(getRoleName(), this.newName); |
58 | 0 | } |
59 | ||
60 | /** | |
61 | * @since 0.3.0 | |
62 | */ | |
63 | @Override | |
64 | public void undo (PolicyBean policy) throws Exception { | |
65 | 0 | getRoleHierarchyBean().renameRole(this.newName, getRoleName()); |
66 | 0 | } |
67 | } |