OSDN Git Service

Initial commit
[ultramonkey-l7/l7gui.git] / src / WebContent / user_add.jsp
1 <%@ page import="org.ultramonkey.l7.model.*,
2                                  org.ultramonkey.l7.controller.*,
3                                  org.ultramonkey.l7.view.*, java.util.*"
4         language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
5 %>
6 <%
7
8         /*
9          * check session
10          */
11         L7guiServletBase base = new L7guiServletBase();
12         if (session.isNew() || base.checkSession(session) == false) {
13                 MessageView error = new MessageView(41413, LogCategorySet.GUI_USER_AUTHENTICATION,
14                                 Message.INVALID_SESSSION);
15                 session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
16                 response.sendRedirect(RedirectPages.LOGIN);
17                 return;
18         }
19
20
21         /*
22          * get result message
23          */
24         MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
25         String errorMessage = "";
26         int errorNumber = 0;
27         String  category = "";
28         if (message != null) {
29                 errorMessage = message.getMessage();
30                 errorNumber = message.getErrno();
31                 category = message.getCategory();
32                 session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
33         }
34
35         /*
36          * get user info 
37          */     
38         UserManager user = UserManager.getInstance();
39         Vector<UserData> userList;
40         try {
41                 userList = user.getUserList();
42         }
43         catch(Exception e){
44                 MessageView error = new MessageView(41414, LogCategorySet.GUI_IO_FILE,
45                 Message.READ_ERROR);
46         session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
47         response.sendRedirect(RedirectPages.LOGIN);
48         return;
49         }
50         if ( userList == null ){
51                 MessageView error = new MessageView(41415, LogCategorySet.GUI_IO_FILE,
52                 Message.UNEXPECTED_ERROR);
53                 session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
54                 response.sendRedirect(RedirectPages.LOGIN);
55                 return;
56         }
57         int userCount = userList.size();
58
59         /*
60          * get Input User Data
61          */
62         UserData inputUser = (UserData)session.getAttribute(SessionKeys.INPUT_USERDATA);
63         if ( inputUser != null ){
64                         session.setAttribute(SessionKeys.INPUT_USERDATA, null);
65                 }
66
67         
68         /*
69          * get cluster status
70          */
71         L7guiFramework framework = new L7guiFramework(); 
72         ClusterData cd = framework.getClusterData();
73         if (cd == null) {
74                 MessageView error = new MessageView(41416, LogCategorySet.GUI_IO_COMMAND,
75                                 Message.CLUSTER_DATA_ERROR);
76                 session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
77                 response.sendRedirect(RedirectPages.LOGIN);
78                 return;
79         }
80
81         /*
82          * fix style seat
83          */
84         String cssSeat = "l7gui_single_style.css";
85         if ( cd.self_status == ClusterStatus.ACTIVE ){
86                 cssSeat = "l7gui_act_style.css";
87         }
88         else if ( cd.self_status == ClusterStatus.STANDBY ){
89                 cssSeat = "l7gui_sby_style.css";
90         }
91
92 %>
93
94
95 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
96 <html>
97         <head>
98                 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
99                 <meta http-equiv="Pragma" content="no-cache">
100                 <meta http-equiv="Cache-Control" content="no-cache">
101                 <meta http-equiv="Expires" content="0"> 
102                 <meta http-equiv="Content-Script-Type" content="text/javascript" />
103                 <meta http-equiv="Content-Style-Type" content="text/css" />
104                 <script src="l7gui.js" type="text/javascript"></script>
105                 <noscript> 
106                         <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
107                 </noscript> 
108                 <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
109                 <link rel="shortcut icon" href="images/favicon.ico" />
110
111                         <title>Add User</title>
112                 </head>
113
114                 <body class="normal">
115                 <jsp:include page="menu.jsp" flush="false"/>
116
117                 <div id="content">
118
119         <h1>Add User </h1>
120
121         <% if ( userCount >= 16){
122         %>
123                         <p class="error"><%=Message.USER_MAX %></p>
124         <% 
125                 }
126                 else {
127                         if (message != null) {
128         %>
129                                 <p class="error">[<%=category %> - <%=errorNumber %>]</p>
130                                 <p class="error"><%=errorMessage %></p>
131                                 <%
132                                         }
133                                 %>
134
135         <form method="post" action="UserAddServlet">
136  
137                 <fieldset>
138                 <legend>Add User Info</legend>  
139                 <table class="status">
140                 <tr>
141                         <th>
142                                 <label for="userId">User ID</label>
143                         </th>
144                         <td>
145                         <% if ( (inputUser != null) && (inputUser.userName != null) ){ %>
146                                 <input type="text" name="userId" value="<%=inputUser.userName %>"  size="20" maxlength="16">
147                         <%} 
148                         else {%>
149                                 <input type="text" name="userId" size="20" maxlength="16">
150                         <%} %>
151                         </td>
152                         <td>
153                                 <p class="item">Required Field</p>
154                                 <p class="required">Between 1 and 16 one-byte characters in English</p>                         
155                         </td>
156                 </tr>
157                 <tr>
158                         <th>
159                                 <label for="description">Description</label>
160                         </th>
161                         <td>
162                         <% if ( (inputUser != null) && (inputUser.description != null) ){ %>
163                                 <input type="text" name="description" value="<%=inputUser.description %>" size="20" maxlength="64">     
164                         <% }
165                         else{
166                         %>
167                                 <input type="text" name="description" size="20" maxlength="64">
168                         <%
169                         }
170                         %>
171                         </td>
172                         <td>
173                                 <p class="required">Up to 64 one-byte characters in English</p>
174                         </td>
175                 </tr>
176                 <tr>
177                         <th>
178                                 <label for="password">Password</label>
179                         </th>
180                         <td>
181                         <input type="password" name="new1_passwd" size="20" maxlength="16">
182                         </td>
183                         <td>
184                                 <p class="item">Required Field</p>
185                                 <p class="required">Between 6 and 16 one-byte characters in English</p>                         
186                         </td>
187                 </tr>
188                 <tr>
189                         <th>
190                                 <label for="password">Re-type Password</label>
191                         </th>
192                         <td>
193                         <input type="password" name="new2_passwd" size="20" maxlength="16">
194                         </td>
195                         <td>
196                                 <p class="item">Required Field</p>
197                                 <p class="required">Between 6 and 16 one-byte characters in English</p>                         
198                         </td>
199                 </tr>
200                 </table>
201                 </fieldset>
202                 
203         <br>
204                 <input type="submit" name="button" value="<%= ButtonMode.ADD %>" onClick="return confirm(user_add)" />
205                 <input type = "Reset" value = "Clear">
206         
207         </form>
208         <%
209         }
210         %>
211         </div>
212         </body>
213 </html>