OSDN Git Service

Initial commit
[ultramonkey-l7/l7gui.git] / src / WebContent / save.jsp
1 <%@ page import="org.ultramonkey.l7.model.*,
2                                  org.ultramonkey.l7.controller.*,
3                                  org.ultramonkey.l7.view.*, java.util.*, 
4                                  java.io.File, java.util.Calendar, java.util.Date, java.text.*"
5         language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
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(41361, 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          * get result message
22          */
23         MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
24         String errorMessage = "";
25         int errorNumber = 0;
26         String category = "";
27         if (message != null) {
28                 errorMessage = message.getMessage();
29                 errorNumber = message.getErrno();
30                 category = message.getCategory();
31                 session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
32         }
33         
34         /*
35          * get command message
36          */
37         MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE);
38         String commandMessage = "";
39         int commandNumber = 0;
40         String commandCategory = "";
41         if (commandmessage != null) {
42                 commandMessage = commandmessage.getMessage();
43                 commandNumber = commandmessage.getErrno();
44                 commandCategory = commandmessage.getCategory();
45                 session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
46         }
47
48         /*
49          * get save status
50          */
51         String saveLogStatus = (String)session.getAttribute(SessionKeys.LOG_SAVE_STATE);
52         String saveVsStatus = (String)session.getAttribute(SessionKeys.VS_SAVE_STATE);
53         
54         if ((saveLogStatus == null) || (saveVsStatus == null)){
55                 MessageView error = new MessageView(41362, LogCategorySet.GUI_USER_AUTHENTICATION,
56                                 Message.UNEXPECTED_ERROR);
57                 session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
58                 response.sendRedirect(RedirectPages.LOGIN);
59                 return;
60         }
61         
62         if (saveLogStatus.equals(SessionKeys.SAVE)){
63                 saveLogStatus = "Save";
64         }
65         else if (saveLogStatus.equals(SessionKeys.NO_SAVE)){
66                 saveLogStatus = "No Save";
67         }
68         
69         if(saveVsStatus.equals(SessionKeys.SAVE)){
70                 saveVsStatus = "Save";
71         }
72         else if (saveVsStatus.equals(SessionKeys.NO_SAVE)){
73                 saveVsStatus = "No Save";
74         }
75         
76         /*
77          * get save file info
78          */
79         final String logConfName = "/etc/l7vs/l7vs.cf";
80
81         final String vsConfName = "/etc/ha.d/conf/l7directord.cf";
82
83         File logConfFile = new File(logConfName);
84         File vsConfFile = new File(vsConfName);
85         String logDisplayTime  = null;
86         String vsDisplayTime = null;
87         long logConfTime = logConfFile.lastModified();
88         long vsConfTime = vsConfFile.lastModified();
89
90         if (logConfTime == 0){
91                 logDisplayTime = "-";
92         }
93         else{
94                 // get logConfTime
95                 SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.JAPAN);
96                 logDisplayTime = sdf.format(new Long(logConfTime));
97 }       
98
99         if (vsConfTime == 0){
100                 vsDisplayTime = "-";
101         }
102         else{
103                 // get vsConfTime
104                 SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.JAPAN);
105                 vsDisplayTime = sdf.format(new Long(vsConfTime));
106         }
107         
108          
109         /*
110          * get cluster status
111          */
112         L7guiFramework framework = new L7guiFramework(); 
113         ClusterData cd = framework.getClusterData();
114         if (cd == null) {
115                 MessageView error = new MessageView(41363, LogCategorySet.GUI_IO_COMMAND,
116                                 Message.CLUSTER_DATA_ERROR);
117                 session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
118                 response.sendRedirect(RedirectPages.LOGIN);
119                 return;
120         }
121
122         /*
123          * fix style seat
124          */
125         String cssSeat = "l7gui_single_style.css";
126         if ( cd.self_status == ClusterStatus.ACTIVE ){
127                 cssSeat = "l7gui_act_style.css";
128         }
129         else if ( cd.self_status == ClusterStatus.STANDBY ){
130                 cssSeat = "l7gui_sby_style.css";
131         }       
132 %>
133
134 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
135 <html>
136         <head>
137                 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
138                 <meta http-equiv="Pragma" content="no-cache">
139                 <meta http-equiv="Cache-Control" content="no-cache">
140                 <meta http-equiv="Expires" content="0"> 
141                 <meta http-equiv="Content-Script-Type" content="text/javascript" />
142                 <meta http-equiv="Content-Style-Type" content="text/css" />
143                 <script src="l7gui.js" type="text/javascript"></script>
144                 <noscript> 
145         <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
146                 </noscript> 
147                 <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
148                 <link rel="shortcut icon" href="images/favicon.ico" />
149
150                 <title>Save Resources</title>
151         </head>
152
153         <body class="normal">
154         <jsp:include page="menu.jsp" flush="false"/>
155
156         <div id="content">
157
158                 <h1>Save Resources</h1>
159         
160                 <%
161                         if (message != null) {
162                 %>
163                 
164                 <p class="error">[<%=category %>-<%=errorNumber %>]</p>
165                 <p class="error"><%=errorMessage %></p>
166                 
167                 <%
168                         }
169                         else if ((commandmessage != null) && (commandMessage != null) ){
170                 %>
171                 <p class="success">[<%=commandCategory %>-<%=commandNumber %>]</p>
172                 <p class="success"><%=commandMessage %></p>
173                 <%              
174                         }
175                 %>      
176                 
177         
178                 <form method="post" action="SaveStateServlet">
179                 <fieldset class="">
180                 <legend>Save / No Save Info</legend>
181                 
182                 <table  class="infotable" cellspacing="0">
183                         <thead>
184                         <tr>
185                                 <th>Save<br />CHECK</th><th>Save / No Save</th><th>Category</th><th>Description</th><th>File Name</th><th>Last Save Time</th></tr>
186                         </thead> 
187                         <tbody>
188                         <tr>
189                                 <td class="center"><input type="checkbox" name="save_category" value="save_log" /></td>
190                                 <td><%= saveLogStatus %></td>
191                                 <td>Log</td>
192                                 <td> Log setting<br />(except GUI &amp; Sync)</td>
193                                 <td><%=logConfName %></td>
194                                 <td><%=logDisplayTime %></td>
195                         </tr>
196                         <tr>
197                                 <td class="center"><input type="checkbox" name="save_category" value="save_service" /></td>
198                                 <td><%= saveVsStatus %></td>                    
199                                 <td>Service</td>
200                                 <td>VirtualService settings</td>
201                                 <td><%=vsConfName %></td>
202                                 <td><%=vsDisplayTime %></td>
203                         </tr>
204                         </tbody>
205                 </table>
206                 </fieldset>
207
208
209                 <input type="submit" name="button" value="<%=ButtonMode.SAVE%>" onClick="return confirm(save)" />       
210                 </form>
211
212         </div>
213         </body>
214 </html>