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 Long id; |
||
14 | private String name; |
||
15 | private User owner; |
||
16 | |||
17 | protected InetDomain() |
||
18 | { |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * |
||
23 | * @hibernate.id generator-class="native" |
||
24 | */ |
||
25 | public Long getId() |
||
26 | { |
||
27 | return id; |
||
28 | } |
||
29 | |||
921 | dev | 30 | protected void setId(Long id) |
919 | dev | 31 | { |
32 | this.id = id; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * |
||
37 | * @hibernate.property |
||
38 | */ |
||
39 | public String getName() |
||
40 | { |
||
41 | return name; |
||
42 | } |
||
43 | |||
921 | dev | 44 | protected void setName(String name) |
919 | dev | 45 | { |
46 | this.name = name; |
||
47 | } |
||
48 | |||
921 | dev | 49 | public void setName(User editor, String name) |
50 | throws ModelException |
||
51 | { |
||
52 | if(!editableBy(editor)) |
||
53 | throw new ModelSecurityException(); |
||
54 | |||
55 | this.name = name; |
||
56 | } |
||
57 | |||
919 | dev | 58 | /** |
59 | * |
||
60 | * @hibernate.many-to-one |
||
61 | */ |
||
62 | public User getOwner() |
||
63 | { |
||
64 | return owner; |
||
65 | } |
||
66 | |||
921 | dev | 67 | protected void setOwner(User owner) |
919 | dev | 68 | { |
69 | this.owner = owner; |
||
70 | } |
||
71 | |||
921 | dev | 72 | public void setOwner(User editor, User owner) |
73 | throws ModelException |
||
74 | { |
||
75 | if(!editableBy(editor)) |
||
76 | throw new ModelSecurityException(); |
||
77 | |||
78 | this.owner = owner; |
||
79 | } |
||
80 | |||
919 | dev | 81 | public String getTypeKey() |
82 | { |
||
924 | dev | 83 | return ak.hostadmiral.core.CoreResources.TYPE_DOMAIN; |
919 | dev | 84 | } |
85 | |||
86 | public String getIdentKey() |
||
87 | { |
||
924 | dev | 88 | return ak.hostadmiral.core.CoreResources.IDENT_DOMAIN; |
919 | dev | 89 | } |
90 | |||
91 | public Object[] getIdentParams() |
||
92 | { |
||
93 | return new Object[] { getName() }; |
||
94 | } |
||
95 | |||
96 | public boolean viewableBy(User user) |
||
97 | { |
||
98 | return user.isSuperuser() || user.equals(owner); |
||
99 | } |
||
100 | |||
101 | public boolean editableBy(User user) |
||
102 | { |
||
103 | return user.isSuperuser(); |
||
104 | } |
||
105 | |||
106 | public boolean deleteableBy(User user) |
||
107 | { |
||
108 | return user.isSuperuser(); |
||
109 | } |
||
921 | dev | 110 | |
111 | protected static boolean allowedToCreate(InetDomainManager manager, User editor) |
||
112 | throws ModelException |
||
113 | { |
||
114 | return editor.isSuperuser(); |
||
115 | } |
||
919 | dev | 116 | } |