KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > ui > admin > struts > formbeans > UserAdminForm


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * 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. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */

18
19 package org.apache.roller.ui.admin.struts.formbeans;
20
21 import java.util.Locale JavaDoc;
22 import org.apache.roller.ui.authoring.struts.formbeans.UserFormEx;
23
24 import org.apache.struts.action.ActionMapping;
25 import org.apache.roller.RollerException;
26 import org.apache.roller.pojos.UserData;
27 import org.apache.roller.ui.authoring.struts.forms.UserForm;
28
29 import javax.servlet.http.HttpServletRequest JavaDoc;
30
31 /**
32  * These properties are not persistent and are only needed for the UI.
33  *
34  * @struts.form name="userAdminForm"
35  * @author dmj
36  */

37 public class UserAdminForm extends UserFormEx
38 {
39     private boolean mDelete = false;
40     //private Boolean mUserEnabled = Boolean.FALSE;
41
private Boolean JavaDoc mUserAdmin = Boolean.FALSE;
42     private boolean newUser = false;
43
44     public UserAdminForm()
45     {
46         super();
47     }
48
49     public UserAdminForm(UserData userData, java.util.Locale JavaDoc locale ) throws RollerException
50     {
51         super(userData, locale);
52     }
53
54     /**
55      * Returns true if delete requested.
56      * @return boolean
57     **/

58     public boolean getDelete()
59     {
60         return mDelete;
61     }
62
63     /**
64      * Sets the Delete member.
65      */

66     public void setDelete(boolean delete)
67     {
68         mDelete = delete;
69     }
70     
71     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request)
72     {
73         super.reset(mapping, request);
74         mDelete = false;
75     }
76
77     /*
78      * @return Returns the mEnabled.
79      */

80     //public Boolean getUserEnabled()
81
//{
82
//return this.mUserEnabled;
83
//}
84

85     /*
86      * @param enabled The mEnabled to set.
87      */

88     //public void setUserEnabled(Boolean enabled)
89
//{
90
//this.mUserEnabled = enabled;
91
//}
92

93     /**
94      * @return Returns the mUserAdmin.
95      */

96     public Boolean JavaDoc getUserAdmin() {
97         return mUserAdmin;
98     }
99     
100     /**
101      * @param userAdmin The mUserAdmin to set.
102      */

103     public void setUserAdmin(Boolean JavaDoc userAdmin) {
104         mUserAdmin = userAdmin;
105     }
106
107     /** Override to grant/revoke admin role depending on form */
108     public void copyTo(UserData user, Locale JavaDoc locale)
109             throws RollerException
110     {
111         super.copyTo(user, locale);
112         if (mUserAdmin.booleanValue())
113         {
114             user.grantRole("admin");
115         }
116         else
117         {
118             user.revokeRole("admin");
119         }
120     }
121
122     /** Override to set "administration" checkbox depending on user's roles */
123     public void copyFrom(UserData user, Locale JavaDoc locale)
124             throws RollerException
125     {
126         super.copyFrom(user, locale);
127         mUserAdmin = user.hasRole("admin") ? Boolean.TRUE : Boolean.FALSE;
128     }
129
130     public boolean isNewUser()
131     {
132         return newUser;
133     }
134
135     public void setNewUser(boolean newUser)
136     {
137         this.newUser = newUser;
138     }
139 }
140
Popular Tags