Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
924 | dev | 1 | package ak.hostadmiral.core.model; |
919 | dev | 2 | |
924 | dev | 3 | import ak.hostadmiral.util.ModelException; |
4 | import ak.hostadmiral.util.ModelSecurityException; |
||
921 | dev | 5 | |
919 | dev | 6 | /** |
7 | * |
||
8 | * @hibernate.class table="domains" |
||
9 | */ |
||
10 | public class InetDomain |
||
11 | extends GeneralModelObject |
||
12 | { |
||
13 | private String name; |
||
14 | private User owner; |
||
15 | |||
16 | protected InetDomain() |
||
17 | { |
||
18 | } |
||
19 | |||
20 | /** |
||
21 | * |
||
22 | * @hibernate.property |
||
23 | */ |
||
24 | public String getName() |
||
25 | { |
||
26 | return name; |
||
27 | } |
||
28 | |||
921 | dev | 29 | protected void setName(String name) |
919 | dev | 30 | { |
31 | this.name = name; |
||
32 | } |
||
33 | |||
921 | dev | 34 | public void setName(User editor, String name) |
35 | throws ModelException |
||
36 | { |
||
37 | if(!editableBy(editor)) |
||
38 | throw new ModelSecurityException(); |
||
39 | |||
40 | this.name = name; |
||
41 | } |
||
42 | |||
919 | dev | 43 | /** |
44 | * |
||
45 | * @hibernate.many-to-one |
||
46 | */ |
||
47 | public User getOwner() |
||
48 | { |
||
49 | return owner; |
||
50 | } |
||
51 | |||
921 | dev | 52 | protected void setOwner(User owner) |
919 | dev | 53 | { |
54 | this.owner = owner; |
||
55 | } |
||
56 | |||
921 | dev | 57 | public void setOwner(User editor, User owner) |
58 | throws ModelException |
||
59 | { |
||
60 | if(!editableBy(editor)) |
||
61 | throw new ModelSecurityException(); |
||
62 | |||
63 | this.owner = owner; |
||
64 | } |
||
65 | |||
919 | dev | 66 | public String getTypeKey() |
67 | { |
||
924 | dev | 68 | return ak.hostadmiral.core.CoreResources.TYPE_DOMAIN; |
919 | dev | 69 | } |
70 | |||
71 | public String getIdentKey() |
||
72 | { |
||
924 | dev | 73 | return ak.hostadmiral.core.CoreResources.IDENT_DOMAIN; |
919 | dev | 74 | } |
75 | |||
76 | public Object[] getIdentParams() |
||
77 | { |
||
78 | return new Object[] { getName() }; |
||
79 | } |
||
80 | |||
81 | public boolean viewableBy(User user) |
||
82 | { |
||
83 | return user.isSuperuser() || user.equals(owner); |
||
84 | } |
||
85 | |||
86 | public boolean editableBy(User user) |
||
87 | { |
||
88 | return user.isSuperuser(); |
||
89 | } |
||
90 | |||
91 | public boolean deleteableBy(User user) |
||
92 | { |
||
93 | return user.isSuperuser(); |
||
94 | } |
||
921 | dev | 95 | |
96 | protected static boolean allowedToCreate(InetDomainManager manager, User editor) |
||
97 | throws ModelException |
||
98 | { |
||
99 | return editor.isSuperuser(); |
||
100 | } |
||
919 | dev | 101 | } |