KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > pojos > PermissionsData


1 /*
2  * Copyright 2005 Sun Microsystems, Inc.
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
17 package org.apache.roller.pojos;
18
19 /**
20  * Represents a user's permissions within a website.
21  *
22  * @ejb:bean name="PermissionsData"
23  * @struts.form include-all="true"
24  * @hibernate.class lazy="false" table="roller_user_permissions"
25  * @hibernate.cache usage="read-write"
26  *
27  * @author Dave Johnson
28  */

29 public class PermissionsData extends PersistentObject
30 {
31     private String JavaDoc id = null;
32     private WebsiteData website = null;
33     private UserData user = null;
34     private boolean pending = true;
35     public static short LIMITED = 0x00; // 0000
36
public static short AUTHOR = 0x01; // 0001
37
public static short ADMIN = 0x03; // 0011
38
private short permissionMask = LIMITED;
39     
40     /** Creates a new instance of PermissionsData */
41     public PermissionsData()
42     {
43     }
44
45     /**
46      * Check for specific permission.
47      */

48     public boolean has(short priv)
49     {
50         return (getPermissionMask() & priv) == priv;
51     }
52     /**
53      * @ejb:persistent-field
54      * @hibernate.id column="id"
55      * generator-class="uuid.hex" unsaved-value="null"
56      */

57     public String JavaDoc getId()
58     {
59         return id;
60     }
61     /** @ejb:persistent-field */
62     public void setId(String JavaDoc id)
63     {
64         this.id = id;
65     }
66     /**
67      * @hibernate.many-to-one column="website_id" cascade="none" not-null="false"
68      */

69     public WebsiteData getWebsite()
70     {
71         return website;
72     }
73     public void setWebsite(WebsiteData website)
74     {
75         this.website = website;
76     }
77     /**
78      * @hibernate.many-to-one column="user_id" cascade="none" not-null="false"
79      */

80     public UserData getUser()
81     {
82         return user;
83     }
84     public void setUser(UserData user)
85     {
86         this.user = user;
87     }
88     /**
89      * Bit mask that encodes user's permissions in website.
90      * @ejb:persistent-field
91      * @hibernate.property column="permission_mask" non-null="true" unique="false"
92      */

93     public short getPermissionMask()
94     {
95         return permissionMask;
96     }
97     /** @ejb:persistent-field */
98     public void setPermissionMask(short permissionMask)
99     {
100         this.permissionMask = permissionMask;
101     }
102     /**
103      * True if user has been invited to join site but has not yet accepted.
104      * And false if user is member of website.
105      * @ejb:persistent-field
106      * @hibernate.property column="pending" non-null="true" unique="false"
107      */

108     public boolean isPending()
109     {
110         return pending;
111     }
112     /** @ejb:persistent-field */
113     public void setPending(boolean pending)
114     {
115         this.pending = pending;
116     }
117     /**
118      * Set data from other object (no-op).
119      */

120     public void setData(PersistentObject vo)
121     {
122         // no-op
123
}
124 }
125
Popular Tags