--- /dev/null
+#!/bin/sh
+
+SYNC_DIR=`dirname $0`
+JAVA_HOME=/usr/java/jdk1.5.0_14
+CLASSPATH=${SYNC_DIR}/lib/log4j-1.2.13.jar:${SYNC_DIR}/lib/l7gui.jar:${SYNC_DIR}/lib/mail.jar
+
+${JAVA_HOME}/bin/java -classpath ${CLASSPATH} org.ultramonkey.l7.model.L7SyncCommand $*
--- /dev/null
+# default: off
+# description: The UltraMonkey-L7 sync server.
+service L7SyncCommand
+{
+ socket_type = stream
+ wait = no
+ user = tomcat
+ server = /usr/local/l7vs/L7SyncCommand
+ server_args = -s
+ disable = no
+ port = 60000
+ type = UNLISTED
+}
--- /dev/null
+#====================================================================
+# l7gui.cf
+#====================================================================
+#--------------------------------------------------------------------
+# sync settings
+# actHost : IP address of this server used to synchronize
+# sbyHost : IP address of peer server used to synchronize
+# sbyPort : Port number of peer server used to synchronize
+#--------------------------------------------------------------------
+#actHost=192.168.0.1
+#sbyHost=192.168.0.2
+#sbyPort=60000
+
+#--------------------------------------------------------------------
+# l7gui session setting
+# max_session_time : Session time-out seconds
+#--------------------------------------------------------------------
+max_session_time=1200
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="output" path="build/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>l7gui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+#Wed Apr 23 11:39:37 JST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
--- /dev/null
+#Wed Apr 23 11:39:39 JST 2008
+classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER/owners=jst.java\:5.0
+classpath.helper/org.eclipse.jst.server.core.container\:\:org.eclipse.jst.server.tomcat.runtimeTarget\:\:Apache\ Tomcat\ v5.5/owners=jst.web\:2.4
+eclipse.preferences.version=1
--- /dev/null
+#Wed Apr 23 11:44:07 JST 2008
+XDOCLETBUILDERACTIVE=false
+XDOCLETHOME=
+XDOCLETUSEGLOBAL=false
+XDOCLETVERSION=1.2.1
+eclipse.preferences.version=1
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+<wb-module deploy-name="l7gui">
+<wb-resource deploy-path="/" source-path="/WebContent"/>
+<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
+<property name="java-output-path" value="build/classes"/>
+<property name="context-root" value="l7gui"/>
+</wb-module>
+</project-modules>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <runtime name="Apache Tomcat v5.5"/>
+ <fixed facet="jst.java"/>
+ <fixed facet="jst.web"/>
+ <installed facet="jst.java" version="5.0"/>
+ <installed facet="jst.web" version="2.4"/>
+</faceted-project>
--- /dev/null
+Manifest-Version: 1.0
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+ <display-name>l7gui</display-name>
+ <servlet>
+ <description>login servlet</description>
+ <display-name>LoginServlet</display-name>
+ <servlet-name>LoginServlet</servlet-name>
+ <servlet-class>org.ultramonkey.l7.view.LoginServlet</servlet-class>
+ <init-param>
+ <description>user name despriction</description>
+ <param-name>UserName</param-name>
+ <param-value></param-value>
+ </init-param>
+ <init-param>
+ <description>password description</description>
+ <param-name>Password</param-name>
+ <param-value></param-value>
+ </init-param>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>LoginServlet</servlet-name>
+ <url-pattern>/LoginServlet</url-pattern>
+ </servlet-mapping>
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+ <servlet>
+ <description>
+ VirtualService add servlet</description>
+ <display-name>
+ VSAddServlet</display-name>
+ <servlet-name>VSAddServlet</servlet-name>
+ <servlet-class>
+ org.ultramonkey.l7.view.VSAddServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>VSAddServlet</servlet-name>
+ <url-pattern>/VSAddServlet</url-pattern>
+ </servlet-mapping>
+ <servlet>
+ <description>
+ VirtualService remove servlet</description>
+ <display-name>
+ VSRemoveServlet</display-name>
+ <servlet-name>VSRemoveServlet</servlet-name>
+ <servlet-class>
+ org.ultramonkey.l7.view.VSRemoveServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>VSRemoveServlet</servlet-name>
+ <url-pattern>/VSRemoveServlet</url-pattern>
+ </servlet-mapping>
+ <servlet>
+ <description>
+ VirtualService modify servlet</description>
+ <display-name>
+ VSModServlet</display-name>
+ <servlet-name>VSModServlet</servlet-name>
+ <servlet-class>
+ org.ultramonkey.l7.view.VSModServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <description>
+ </description>
+ <display-name>
+ SoRun</display-name>
+ <servlet-name>SoRunServlet</servlet-name>
+ <servlet-class>
+ org.ultramonkey.l7.view.SoRunServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <description>
+ </description>
+ <display-name>
+ SnmpAgentServlet</display-name>
+ <servlet-name>SnmpAgentServlet</servlet-name>
+ <servlet-class>
+ org.ultramonkey.l7.view.SnmpAgentServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <description>
+ </description>
+ <display-name>
+ ReplicationModeChangeServlet</display-name>
+ <servlet-name>ReplicationModeChangeServlet</servlet-name>
+ <servlet-class>
+ org.ultramonkey.l7.view.ReplicationModeChangeServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <description>
+ </description>
+ <display-name>
+ ReplicationInfoChangeServlet</display-name>
+ <servlet-name>ReplicationInfoChangeServlet</servlet-name>
+ <servlet-class>
+ org.ultramonkey.l7.view.ReplicationInfoChangeServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <description>
+ </description>
+ <display-name>
+ ReplicationRunServlet</display-name>
+ <servlet-name>ReplicationRunServlet</servlet-name>
+ <servlet-class>
+ org.ultramonkey.l7.view.ReplicationRunServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <description>
+ </description>
+ <display-name>
+ SaveStateServlet</display-name>
+ <servlet-name>SaveStateServlet</servlet-name>
+ <servlet-class>
+ org.ultramonkey.l7.view.SaveStateServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <description>
+ </description>
+ <display-name>
+ UserModServlet</display-name>
+ <servlet-name>UserModServlet</servlet-name>
+ <servlet-class>
+ org.ultramonkey.l7.view.UserModServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <description>
+ </description>
+ <display-name>
+ SyncStateServlet</display-name>
+ <servlet-name>SyncStateServlet</servlet-name>
+ <servlet-class>
+ org.ultramonkey.l7.view.SyncStateServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <description>
+ </description>
+ <display-name>
+ UserAddServlet</display-name>
+ <servlet-name>UserAddServlet</servlet-name>
+ <servlet-class>
+ org.ultramonkey.l7.view.UserAddServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <description>
+ </description>
+ <display-name>
+ UserRemoveServlet</display-name>
+ <servlet-name>UserRemoveServlet</servlet-name>
+ <servlet-class>
+ org.ultramonkey.l7.view.UserRemoveServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <description>
+ </description>
+ <display-name>
+ LogOutputServlet</display-name>
+ <servlet-name>LogOutputServlet</servlet-name>
+ <servlet-class>
+ org.ultramonkey.l7.view.LogOutputServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <description>
+ </description>
+ <display-name>
+ LogLevelServlet</display-name>
+ <servlet-name>LogLevelServlet</servlet-name>
+ <servlet-class>
+ org.ultramonkey.l7.view.LogLevelServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <description>
+ </description>
+ <display-name>
+ MonitorSetServlet</display-name>
+ <servlet-name>MonitorSetServlet</servlet-name>
+ <servlet-class>
+ org.ultramonkey.l7.view.MonitorSetServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>VSModServlet</servlet-name>
+ <url-pattern>/VSModServlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>SoRunServlet</servlet-name>
+ <url-pattern>/SoRunServlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>SnmpAgentServlet</servlet-name>
+ <url-pattern>/SnmpAgentServlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>ReplicationModeChangeServlet</servlet-name>
+ <url-pattern>/ReplicationModeChangeServlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>ReplicationInfoChangeServlet</servlet-name>
+ <url-pattern>/ReplicationInfoChangeServlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>ReplicationRunServlet</servlet-name>
+ <url-pattern>/ReplicationRunServlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>SaveStateServlet</servlet-name>
+ <url-pattern>/SaveStateServlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>UserModServlet</servlet-name>
+ <url-pattern>/UserModServlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>SyncStateServlet</servlet-name>
+ <url-pattern>/SyncStateServlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>UserAddServlet</servlet-name>
+ <url-pattern>/UserAddServlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>UserRemoveServlet</servlet-name>
+ <url-pattern>/UserRemoveServlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>LogOutputServlet</servlet-name>
+ <url-pattern>/LogOutputServlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>LogLevelServlet</servlet-name>
+ <url-pattern>/LogLevelServlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>MonitorSetServlet</servlet-name>
+ <url-pattern>/MonitorSetServlet</url-pattern>
+ </servlet-mapping>
+</web-app>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*, org.ultramonkey.l7.controller.*, org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache" />
+ <meta http-equiv="Cache-Control" content="no-cache" />
+ <meta http-equiv="Expires" content="0" />
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <link rel="stylesheet" type="text/css" href="l7gui_basic_style.css" />
+ <link rel="shortcut icon" href="images/favicon.ico"/>
+
+ <title>Login</title>
+ </head>
+
+ <body class="center">
+
+ <img src="images/ultramonkey.gif"
+ alt="UltraMonkey-l7 logo" width="518" height="68">
+ <img src="images/monkey_wht.jpg" alt="UltraMonkey-L7 graffic"
+ width="100" height="100" align="top">
+
+
+
+<%
+ MessageView mv = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ if (mv != null) {
+ String message = mv.getMessage();
+ int errno = mv.getErrno();
+ String category = mv.getCategory();
+ out.println("<p class=\"error\">[" + category + "-" + errno + "] " + message + "</p>");
+ }
+ session.invalidate();
+%>
+
+
+ <script type="text/javascript">
+ if (navigator.cookieEnabled){
+ document.writeln("<form action=\"LoginServlet\" method=\"post\" name=\"login\">");
+ document.writeln("<table class=\"loginStatus\">");
+ document.writeln("<tr><th>User ID</th>");
+ document.writeln("<td><input type=\"text\" name=\"uid\" id =\"uid\" size=\"20\" maxlength=\"16\"></td>");
+ document.writeln("<td><p class=\"item\">Required Field</p>");
+ document.writeln("<p class=\"required\">Bettween 1 and 16 one-byte characters in English.</p></td>");
+ document.writeln("</tr>");
+ document.writeln("<tr><th>Password</th>");
+ document.writeln("<td><input type=\"password\" name=\"passwd\" id =\"passwd\" size=\"20\" maxlength=\"16\"></td>");
+ document.writeln("<td><p class=\"item\">Required Field</p>");
+ document.writeln("<p class=\"required\">Bettween 6 and 16 one-byte characters in English.</p></td>");
+ document.writeln("</tr></table>");
+ document.writeln("<input type=\"submit\" value=\"Login\" />");
+ document.writeln("<input type=\"reset\" value=\"Clear\" />");
+ document.writeln("</form>");
+ }
+ else {
+ document.writeln("<p class=\"error\"> Cookie : OFF</p>");
+ document.writeln("<p class=\"error\"> Please change the settings of one's browser to enable Cookie. </p>");
+ }
+</script>
+
+<noscript>
+ <p class="error"> JavaScript : OFF</p>
+ <p class="error"> Please change the settings of one's browser to enable JavaScript. </p>
+
+</noscript>
+</body>
+
+</html>
--- /dev/null
+// button confirm messages
+var add_vs_apply = 'Add a VirtualService(Apply) OK?\nDisable Monitor Settings!!\n';
+var add_vs_save = 'Add a VirtualService(Save) OK?\n';
+var add_vs_savesync = 'Add a VirtualService(Save+Sync) OK?\n';
+var modify_vs_apply = 'Modify a VirtualService(Apply) OK?\nDisable Monitor Settings!!\n';
+var modify_vs_save = 'Modify a VirtualService(Save) OK?\n';
+var modify_vs_savesync = 'Modify a VirtualService(Save+Sync) OK?\n';
+var remove_vs_apply = 'Remove a VirtualService(Apply) OK?\n';
+var remove_vs_save = 'Remove a VirtualService(Save) OK?\n';
+var remove_vs_savesync = 'Remove a VirtualService(Save+Sync) OK?';
+var monitor_modify_save = 'Modify Monitor Settings(Save) OK?\n';
+var monitor_modify_savesync = 'Modify Monitor Settings(Save+Sync) OK?\n';
+var switch_over = 'Run a Switch-over OK?\n';
+var replication_stop_send = 'Stopping Send Replication Data OK?\n';
+var replication_stop_receive = 'Stopping Receive Replication Data OK?\n';
+var replication_start_send = 'Sending Replication Data OK?\n';
+var replication_start_receive = 'Receiving Replication Data OK?\n';
+var replication_modify_save = 'Modify a Replication Status(Save) OK?\n';
+var replication_modify_savesync = 'Modify a Replication Status(Save+Sync) OK?\n';
+var replication_dump = 'Execute immediate Replication OK?\n';
+var save = 'Save OK?\n';
+var savesync = 'Save+Sync OK?\n';
+var snmp_save = 'Modify a SNMP Agent Interval(Save) OK?\n';
+var snmp_savesync = 'Modify a SNMP Agent Interval(Save+Sync) OK?\n';
+var log_lb_apply = 'Change Load balancer (l7vsd) Log Level (Apply) OK?\n';
+var log_lb_save = 'Change Load balancer (l7vsd) Log Level (Save) OK?\n';
+var log_lb_savesync = 'Change Load balancer (l7vsd) Log Level (Save+Sync) OK?\n';
+var log_adm_save = 'Change Admin command (l7vsadm) Log Level (Save) OK?\n';
+var log_adm_savesync = 'Change Admin command (l7vsadm) Log Level (Save+Sync) OK?\n'
+var log_snmp_apply = 'Change SNMPAgent Log Level (Apply) OK?\n';
+var log_snmp_save = 'Change SNMPAgent Log Level (Save) OK?\n';
+var log_snmp_savesync = 'Change SNMPAgent Log Level (Save+Sync) OK?\n';
+var user_add = 'User Add OK?\n';
+var user_delete = 'User Delete OK?\n';
+var user_modify = 'Modify your info OK?\n';
+var logout = 'Logout OK?\n';
+
+function openTree(name, img) {
+ menu = document.all[name].style;
+ if (menu.display == "none") {
+ menu.display = "block";
+ img.src = "images/minus.gif";
+ }
+ else {
+ menu.display = "none";
+ img.src = "images/plus.gif";
+ }
+}
+
+function vs_modify(page) {
+ document.getElementById("vs_info").action = page;
+ document.vs_info.submit();
+}
--- /dev/null
+@import "l7gui_basic_style.css";
+
+body.ref{
+ /* ACT Color */
+ background-color : #CCFFCC;
+ /* SBY Color */
+ /* background-color : #CCCCCC; */
+ /* SYNGLE Color */
+ /* background-color : #FFCC99; */
+
+ /* background-color : #FFCC66; */
+ /* background-color : #CCFFFF; */
+}
+
+
+body.normal{
+ background-color : #FFFFFF;
+ background-image : url(images/side_act.png);
+ background-position : left;
+ background-repeat : repeat-y;
+}
+
+div#sidebar{
+ background-color: #CCFFCC;
+ position: absolute;
+ top:0;
+ left:0;
+ width: 210px;
+}
+
--- /dev/null
+body{
+ font-family : Verdana, Arial, Helvetica, sans-serif;
+}
+
+body.center{
+ text-align: center;
+}
+
+/* img */
+img{
+ border: 0;
+}
+
+img.top{
+ margin-top : 15px;
+ margin-bottom : 1px;
+ margin-left : 3px;
+ margin-right : 3px;
+}
+
+
+img.arrow1{
+ width:20px;
+ height:58px;
+ margin-left: 30px;
+}
+
+img.arrow2{
+ width:58px;
+ height:20px;
+ margin-left: 10px;
+ margin-right: 10px;
+}
+
+input.topeer{
+ margin-top : 10px;
+ margin-bottom : 5px;
+ margin-left: 10px;
+}
+
+img.icon{
+ margin : 3px;
+}
+
+
+
+
+/* link */
+a{
+ color : #000066;
+ font-size : 110%;
+ font-weight : bold;
+}
+
+a:visited{
+ color: navy;
+ font-weight : bold;
+}
+
+a:hover{
+ color : #FF0066;
+ font-weight : bold;
+}
+
+a.sub{
+ font-size : 95%;
+ font-weight : bold;
+ margin-left : 20px;
+}
+
+
+
+
+h1{
+ font-size : 200%;
+ font-weight : bold;
+ color : #ffffff;
+ background-color : #191970;
+ text-align : left;
+ margin-bottom : 50px;
+ padding-top : 10px;
+ padding-bottom : 10px;
+ padding-left : 20px;
+}
+
+h2{
+ font-size : 150%;
+ color : #191970;
+ padding-left: 10px;
+}
+
+h2.menu{
+ text-align: center;
+}
+
+h3{
+ font-size : 100%;
+ color : #000000;
+ text-indent : 10pt
+}
+
+
+h4{
+ font-size : 80%;
+ color : #000000;
+ padding-top : 5px;
+ padding-bottom : 0px;
+ padding-left : 6px;
+ margin-top : 5px;
+ margin-bottom : 0px;
+ margin-left : 6px;
+}
+
+h4.menu{
+ color: #000000;
+ font-size: 80%;
+ font-weight:bold;
+}
+
+h4.note{
+ color: #FF0066;
+ font-weight:bold;
+ margin-left: 10px;
+ padding-left: 10px;
+}
+
+table.loginStatus{
+ margin : 10px;
+ margin-left:auto;
+ margin-right:auto;
+ border-collapse: collapse;
+ font-size: 80%;
+ cellspacing: 2;
+}
+
+
+table.loginStatus th,
+table.loginStatus td{
+ padding-top: 2px;
+ padding-bottom: 2px;
+ padding-left : 5px;
+ padding-right : 3px;
+ border: 5px solid white;
+}
+
+
+table.loginStatus th{
+ background-repeat:no-repeat;
+ background-color: #FFFFCC;
+ font-weight : bolder;
+ text-align : left;
+ vertical-align : middle;
+ width: 200px;
+}
+
+table.menu {
+ line-height : 150%;
+}
+
+table.menu td{
+ vertical-align: top;
+}
+
+table.status td.bar {
+ color: #FFEBCD;
+ text-align: left;
+}
+
+
+table.infotable{
+ border: 2px #000000 solid;
+ border-collapse: collapse;
+ font-size: 80%;
+ margin-bottom: 15px;
+ margin-top: 15px;
+ margin-left: 15px;
+}
+
+
+table.infotable th,
+table.infotable td{
+ border: 1px solid #000000;
+ padding: 3.0px 5.0px;
+}
+
+table.infotable th.error,
+table.infotable td.error{
+ text-align: center;
+ background-color: #CCCCCC;
+ }
+
+table.infotable th.side_error,
+table.infotable td.side_error{
+ text-align: center;
+ background-color: #CCCCCC;
+ border-right: 2px solid #000000;
+ }
+
+
+table.infotable th.ins,
+table.infotable td.ins{
+ text-align: center;
+ background-color: #CCFFCC;
+ }
+
+table.infotable th.side_ins,
+table.infotable td.side_ins{
+ text-align: center;
+ background-color: #CCFFCC;
+ border-right: 2px solid #000000;
+ }
+
+
+table.infotable th{
+ border-bottom: 3px double #000000;
+ background-color: #FFFFCC;
+ font-weight: bolder;
+ text-align: center;
+}
+
+table.infotable th.center{
+ background-color: #FFFFFF;
+ border-bottom: 3px double #000000;
+ font-weight: bolder;
+ text-align: center;
+}
+
+table.infotable th.left{
+ background-color: #FFFFCC;;
+ font-weight: bolder;
+ text-align: left;
+ border-bottom: 1px #000000;
+
+}
+
+table.infotable th.point{
+ border-bottom: 3px double #000000;
+ border-right: 2px solid #000000;
+ font-weight: bolder;
+ text-align: center;
+}
+
+
+table.infotable th.head{
+ border-bottom: 2px solid #000000;
+ border-right: 2px solid #000000;
+ font-weight: bolder;
+ text-align: center;
+}
+
+table.infotable td.center{
+ text-align: center;
+}
+
+table.infotable td.left{
+ text-align: left;
+}
+
+table.infotable td.right{
+ text-align: right;
+}
+
+
+table.infotable td.left_point{
+ border-right: 2px solid #000000;
+ font-weight: bolder;
+ text-align: center;
+}
+
+
+table.infotable td.null{
+ width: 200px;
+}
+
+table.infotable td.point{
+ text-align: center;
+ border-right: 2px solid #000000;
+}
+
+table.status{
+ /*border: 2px #000000 solid; */
+ border-collapse: collapse;
+ font-size: 80%;
+ cellspacing: 2;
+ margin : 10px;
+}
+
+
+table.status th,
+table.status td{
+ padding-top: 2px;
+ padding-bottom: 2px;
+ padding-left : 5px;
+ padding-right : 3px;
+ border: 5px solid white;
+}
+
+
+table.status th{
+ background-repeat:no-repeat;
+ background-color: #FFFFCC;
+ font-weight : bolder;
+ text-align : left;
+ vertical-align : middle;
+ width: 200px;
+}
+
+table.status th.check{
+ background-repeat:no-repeat;
+ background-color: #FFFFCC;
+ font-weight : bolder;
+ text-align : left;
+ vertical-align : middle;
+ width: 165px;
+}
+
+table.status td{
+ text-align : left;
+ vertical-align : middle;
+ width : 200px;
+}
+
+
+table.status td.check{
+ background-color: #FFFFCC;
+ text-align : center;
+ vertical-align : middle;
+ width : 30px;
+}
+
+div#container{
+ position: relative;
+ width: 100%;
+}
+
+
+div#content{
+ margin-left: 210px;
+}
+
+
+
+p{
+ margin: 0 0 0.75em,0;
+ padding: 0;
+}
+
+
+p.success{
+ color : #191970;
+ font-size : 80%;
+ font-style: italic;
+ font-weight:bold;
+}
+
+
+p.error{
+ color : #FF0000;
+ font-size : 80%;
+ font-style: italic;
+ font-weight:bold;
+}
+
+p.caution{
+ color : #FF0000;
+ font-size : 80%;
+ font-style: italic;
+ font-weight:bold;
+ margin-left: 30px;
+ margin-top: 10px;
+}
+
+
+p.invalid{
+ color : #FF0000;
+ font-style: italic;
+ font-size : 85%;
+ font-weight:bold;
+}
+
+p.required{
+ color : #191970;
+ font-style: italic;
+ font-size : 85%;
+/* font-weight:bold; */
+ line-height: 95%
+}
+
+p.item{
+ color : #FF0000;
+ font-size : 80%;
+ font-style: italic;
+ font-weight:bold;
+ line-height: 95%
+}
+
+p.text{
+ color : #000000;
+ font-size : 100%;
+}
+
+fieldset{
+ padding: 5px;
+ border: 2px dashed #191970;
+ margin-bottom: 10px;
+ margin-top: 10px;
+}
+
+fieldset legend{
+ padding: 10px;
+ font-size: 100%;
+ font-weight: bold;
+ color: #FFFFFF;
+ background-color: #191970;
+}
+
+
+input.menu{
+ vertical-align: middle;
+ margin: -1px -1px 5px 0px;
+}
+
+input.read{
+ vertical-align: middle;
+ background-color: #CCCCCC;
+}
+
+select.read{
+ vertical-align: middle;
+ background-color: #CCCCCC;
+}
\ No newline at end of file
--- /dev/null
+@import "l7gui_basic_style.css";
+
+
+body.ref{
+ /* ACT Color */
+ /*background-color : #CCFFCC;*/
+ /* SBY Color */
+ background-color : #CCCCCC;
+ /* SYNGLE Color */
+ /* background-color : #FFCC99; */
+
+ /* background-color : #FFCC66; */
+ /* background-color : #CCFFFF; */
+}
+
+
+body.normal{
+ background-color : #FFFFFF;
+ background-image : url(images/side_sby.png);
+ background-position : left;
+ background-repeat : repeat-y;
+}
+
+
+div#sidebar{
+ background-color: #CCCCCC; /* sby color */
+ position: absolute;
+ top:0;
+ left:0;
+ width: 210px;
+}
+
--- /dev/null
+@import "l7gui_basic_style.css";
+
+body.ref{
+ /* ACT Color */
+ /* background-color : #CCFFCC; */
+ /* SBY Color */
+ /* background-color : #CCCCCC; */
+ /* SYNGLE Color */
+ background-color : #FFCCCC;
+
+ /* background-color : #FFCC66; */
+ /* background-color : #CCFFFF; */
+}
+
+
+body.normal{
+ background-color : #FFFFFF;
+ background-image : url(images/side_single.png);
+ background-position : left;
+ background-repeat : repeat-y;
+}
+
+
+div#sidebar{
+ background-color: #FFCCCC;
+ position: absolute;
+ top:0;
+ left:0;
+ width: 210px;
+}
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*, java.util.*,
+ java.text.SimpleDateFormat,java.text.NumberFormat"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%
+ /*
+ * check session
+ */
+ if (session.isNew()) {
+ MessageView error = new MessageView(41255, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+ String resultJudge = "success";
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ if ( errorNumber >= ErrNo.ERRORNUMBER )
+ resultJudge = "error";
+ }
+
+ /*
+ * get command message
+ */
+ MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE);
+ String commandMessage = "";
+ int commandNumber = 0;
+ String commandCategory = "";
+ String commandJudge = "success";
+ if (commandmessage != null) {
+ commandMessage = commandmessage.getMessage();
+ commandNumber = commandmessage.getErrno();
+ commandCategory = commandmessage.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ if ( commandNumber >= ErrNo.ERRORNUMBER )
+ commandJudge = "error";
+ }
+
+ /*
+ * get adm_log info
+ */
+ L7guiFramework framework = new L7guiFramework();
+ LogData logdata = framework.getLogData();
+
+ if (logdata == null){
+ MessageView error = new MessageView(41256, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ LogSet data = logdata.admLog;
+
+ if (data == null){
+ MessageView error = new MessageView(41257, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ Vector<LogFileData> logfiles = data.logFiles;
+ if (logfiles == null){
+ MessageView error = new MessageView(41258, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ HashMap<LogData.LogCategory, LogData.LogLevel> logcategoryset = data.logLevel;
+ if (logcategoryset == null){
+ MessageView error = new MessageView(41259, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get cluster status
+ */
+ ClusterData cd = framework.getClusterData();
+
+ if (cd == null){
+ MessageView error = new MessageView(41260, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico"/>
+ <title>Log - Admin command (l7vsadm) -</title>
+ </head>
+
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+ <div id="content">
+
+
+ <h1>Log - Admin command (l7vsadm) -</h1>
+ <%
+ if ( (message != null ) && (errorMessage != null) ) {
+ %>
+
+ <p class="<%=resultJudge %>">[<%=category%>-<%=errorNumber%>]</p>
+ <p class="<%=resultJudge %>"><%=errorMessage%></p>
+
+ <%
+ } else if ( (commandmessage != null) && (commandMessage != null) ) {
+ %>
+ <p class="<%=commandJudge %>">[<%=commandCategory%>-<%=commandNumber%>]</p>
+ <p class="<%=commandJudge %>"><%=commandMessage%></p>
+ <%
+ }
+ %>
+
+ <h2> Download Log File</h2>
+ <h4>Please select the following list you would like to download the log file. </h4>
+ <table class="infotable" cellspacing="0">
+
+ <tr>
+ <th>LogFileName</th><th>LastUpdate</th><th>FileSize(byte)</th>
+ </tr>
+
+ <%
+ SimpleDateFormat dfm = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
+ NumberFormat num = NumberFormat.getInstance();
+ Iterator<LogFileData> i = logfiles.iterator();
+
+ while ( i.hasNext() ){
+ LogFileData log = (LogFileData) i.next();
+
+ if ( log != null && log.fileName != null){
+ out.println("<tr>");
+ out.println("<td>");
+ out.println("<a href=\"LogOutputServlet?type=" + LogCategorySet.L7VSADM + "&log=" + log.fileName + "\">" + log.fileName + "</a>");
+ out.println("</td>");
+ out.println("<td class=\"center\">" + dfm.format(log.time) + "</td>");
+ out.println("<td class=\"right\">" + num.format(log.size) + "</td>");
+ out.println("</tr>");
+ }
+ }
+ %>
+ </table>
+
+ <br />
+
+ <h2>Change Log Level</h2>
+ <h4>Please select log level you would like to change.</h4>
+
+ <form method="post" action="LogLevelServlet" name="log_adm">
+ <input type="hidden" name="type" value="<%=LogCategorySet.L7VSADM %>">
+ <table class="infotable" cellspacing="0">
+
+ <tr>
+ <th>Category</th><th>Level</th>
+ </tr>
+ <%
+ TreeSet<LogData.LogCategory> tree = new TreeSet<LogData.LogCategory>(logcategoryset.keySet());
+ Iterator<LogData.LogCategory> it = tree.iterator();
+
+ while (it.hasNext()) {
+ LogData.LogCategory logcategory = (LogData.LogCategory) it.next();
+
+ if (logcategory != null){
+ %>
+ <tr>
+ <td><%= logcategory %></td>
+ <td>
+ <select id="<%= logcategory %>" name="<%= logcategory %>">
+ <option value="<%=LogData.LogLevel.NONE %>"<%
+ if ( logcategoryset.get(logcategory) == LogData.LogLevel.NONE)
+ out.print(" selected");
+ %>></option>
+ <option value="<%=LogData.LogLevel.INFO %>"<%
+ if ( logcategoryset.get(logcategory) == (LogData.LogLevel.INFO)){
+ out.print(" selected");
+ }
+ %>>INFO</option>
+ <option value="<%=LogData.LogLevel.DEBUG %>"<%
+ if ( logcategoryset.get(logcategory) == (LogData.LogLevel.DEBUG)) {
+ out.print(" selected");
+ }
+ %>>DEBUG</option>
+ <option value="<%=LogData.LogLevel.ERROR %>"<%
+ if (logcategoryset.get(logcategory) == (LogData.LogLevel.ERROR)){
+ out.print(" selected");
+ }
+ %>>ERROR</option>
+ <option value="<%=LogData.LogLevel.WARN %>"<%
+ if ( logcategoryset.get(logcategory) == (LogData.LogLevel.WARN)){
+ out.print(" selected");
+ }
+ %>>WARN</option>
+ <option value="<%=LogData.LogLevel.FATAL %>"<%
+ if ( logcategoryset.get(logcategory) == (LogData.LogLevel.FATAL)){
+ out.print(" selected");
+ }
+ %>>FATAL</option>
+ </select>
+ </td>
+ </tr>
+ <%
+ }
+ }
+ %>
+ </table>
+
+ <br>
+ <input type="submit" name="button" value="<%= ButtonMode.SAVE %>" onClick="return confirm(log_adm_save)" />
+ <%
+ if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) {
+ %>
+ <input type="submit" name="button" value="<%= ButtonMode.SAVESYNC %>" onClick="return confirm(log_adm_savesync)" />
+ <%
+ }
+ %>
+ </form>
+
+ </div>
+ </body>
+</html>
\ No newline at end of file
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*, java.util.*,
+ java.text.SimpleDateFormat,java.text.NumberFormat"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%
+ /*
+ * check session
+ */
+ if (session.isNew()) {
+ MessageView error = new MessageView(41261, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+ String resultJudge = "success";
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ if ( errorNumber >= ErrNo.ERRORNUMBER )
+ resultJudge = "error";
+ }
+
+
+ /*
+ * get directord_log info
+ */
+ L7guiFramework framework = new L7guiFramework();
+ LogData logdata = framework.getLogData();
+
+ if (logdata == null){
+ MessageView error = new MessageView(41262, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ LogSet data = logdata.directorLog;
+
+ if (data == null){
+ MessageView error = new MessageView(41263, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ Vector<LogFileData> logfiles = data.logFiles;
+ if (logfiles == null){
+ MessageView error = new MessageView(41264, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+
+ /*
+ * get cluster status
+ */
+ ClusterData cd = framework.getClusterData();
+
+ if (cd == null){
+ MessageView error = new MessageView(41265, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico"/>
+ <title>Log - Moniter RealServer (l7directord) -</title>
+ </head>
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+ <div id="content">
+
+ <h1>Log - Moniter RealServer (l7directord) -</h1>
+ <%
+ if ( (message != null) && (errorMessage != null) ) {
+ %>
+ <p class="<%=resultJudge %>">[<%=category%>-<%=errorNumber%>]</p>
+ <p class="<%=resultJudge %>"><%=errorMessage%></p>
+ <%
+ }
+ %>
+
+ <h2> Download Log File</h2>
+ <h4>Please select the following list you would like to download the log file. </h4>
+ <table class="infotable" cellspacing="0">
+
+ <tr>
+ <th>LogFileName</th><th>LastUpdate</th><th>FileSize(byte)</th>
+ </tr>
+
+ <%
+ SimpleDateFormat dfm = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
+ NumberFormat num = NumberFormat.getInstance();
+ Iterator<LogFileData> i = logfiles.iterator();
+
+ while ( i.hasNext() ){
+ LogFileData log = (LogFileData) i.next();
+
+ if ( log != null && log.fileName != null){
+
+ out.println("<tr>");
+ out.println("<td>");
+ out.println("<a href=\"LogOutputServlet?type=" + LogCategorySet.L7DIRECTORD + "&log=" + log.fileName + "\">" + log.fileName + "</a>");
+ out.println("</td>");
+ out.println("<td class=\"center\">" + dfm.format(log.time) + "</td>");
+ out.println("<td class=\"right\">" + num.format(log.size) + "</td>");
+ out.println("</tr>");
+ }
+ }
+ %>
+ </table>
+
+ </div>
+ </body>
+</html>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*, java.util.*,
+ java.text.SimpleDateFormat,java.text.NumberFormat"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%
+ /*
+ * check session
+ */
+ if (session.isNew()) {
+ MessageView error = new MessageView(41266, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+ String resultJudge = "success";
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ if ( errorNumber >= ErrNo.ERRORNUMBER )
+ resultJudge = "error";
+ }
+
+ /*
+ * get gui_log info
+ */
+ L7guiFramework framework = new L7guiFramework();
+ LogData logdata = framework.getLogData();
+
+ if (logdata == null){
+ MessageView error = new MessageView(41267, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ LogSet data = logdata.guiLog;
+
+ if (data == null){
+ MessageView error = new MessageView(41268, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ Vector<LogFileData> logfiles = data.logFiles;
+ if (logfiles == null){
+ MessageView error = new MessageView(41269, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ HashMap<LogData.LogCategory, LogData.LogLevel> logcategoryset = data.logLevel;
+ if (logcategoryset == null){
+ MessageView error = new MessageView(41270, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get cluster status
+ */
+ ClusterData cd = framework.getClusterData();
+
+ if (cd == null){
+ MessageView error = new MessageView(41271, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ }
+
+ /*
+ * get log4j properties data
+ */
+ Enumeration<Logger> loggers = (Enumeration<Logger>) Logger.getRootLogger().getLoggerRepository().getCurrentLoggers();
+ TreeMap<String, String> levelMap = new TreeMap<String, String>();
+ while (loggers.hasMoreElements()) {
+ Logger logger = loggers.nextElement();
+ if (logger.getLevel() != null)
+ levelMap.put(logger.getName(), logger.getLevel().toString());
+ else if (Logger.getRootLogger().getLevel() != null)
+ levelMap.put(logger.getName(), Logger.getRootLogger().getLevel().toString());
+ else
+ levelMap.put(logger.getName(), null);
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<%@page import="org.apache.log4j.Hierarchy"%>
+<%@page import="org.apache.log4j.Logger"%>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico"/>
+ <title>Log - GUI (l7gui) -</title>
+ </head>
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+ <div id="content">
+
+ <h1>Log - GUI (l7gui) -</h1>
+ <%
+ if ( (message != null) && (errorMessage != null) ) {
+ %>
+ <p class="<%=resultJudge %>">[<%=category%>-<%=errorNumber%>]</p>
+ <p class="<%=resultJudge %>"><%=errorMessage%></p>
+ <%
+ }
+ %>
+
+ <h2> Download Log File</h2>
+ <h4>Please select the following list you would like to download the log file.</h4>
+
+ <table class="infotable" cellspacing="0">
+
+ <tr>
+ <th>LogFileName</th><th>LastUpdate</th><th>FileSize(byte)</th>
+ </tr>
+
+ <%
+ SimpleDateFormat dfm = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
+ NumberFormat num = NumberFormat.getInstance();
+ Iterator<LogFileData> i = logfiles.iterator();
+ while ( i.hasNext() ){
+ LogFileData log = (LogFileData) i.next();
+
+ if ( log != null && log.fileName != null){
+ out.println("<tr>");
+ out.println("<td>");
+ out.println("<a href=\"LogOutputServlet?type=" + LogCategorySet.L7GUI + "&log=" + log.fileName + "\">" + log.fileName + "</a>");
+ out.println("</td>");
+ out.println("<td class=\"center\">" + dfm.format(log.time) + "</td>");
+ out.println("<td class=\"right\">" + num.format(log.size) + "</td>");
+ out.println("</tr>");
+ }
+ }
+ %>
+ </table>
+
+ <br />
+
+
+ <h2>Current Log Level</h2>
+
+ <form method="post" action="LogLevelServlet" name="log_gui">
+ <input type="hidden" name="type" value="<%=LogCategorySet.L7GUI %>">
+ <table class="infotable" cellspacing="0">
+
+ <tr>
+ <th>Category</th><th>Level</th>
+ </tr>
+ <%
+ Iterator<String> it = levelMap.keySet().iterator();
+ while (it.hasNext()) {
+ String cat = it.next();
+ if (! cat.matches("^l7gui.*$"))
+ continue;
+ %>
+ <tr>
+ <td><%= cat %></td>
+ <td><%= levelMap.get(cat) %></td>
+ </tr>
+ <%
+ }
+ %>
+ </table>
+
+ </form>
+
+ </div>
+ </body>
+</html>
\ No newline at end of file
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*, java.util.*,
+ java.text.SimpleDateFormat,java.text.NumberFormat"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%
+ /*
+ * check session
+ */
+ if (session.isNew()) {
+ MessageView error = new MessageView(41272, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+ String resultJudge = "success";
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ if ( errorNumber >= ErrNo.ERRORNUMBER )
+ resultJudge = "error";
+ }
+
+ /*
+ * get command message
+ */
+ MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE);
+ String commandMessage = "";
+ int commandNumber = 0;
+ String commandCategory = "";
+ if (commandmessage != null) {
+ commandMessage = commandmessage.getMessage();
+ commandNumber = commandmessage.getErrno();
+ commandCategory = commandmessage.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ /*
+ * get ha_log info
+ */
+ L7guiFramework framework = new L7guiFramework();
+ LogData logdata = framework.getLogData();
+
+ if (logdata == null){
+ MessageView error = new MessageView(41273, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ LogSet data = logdata.haLog;
+
+ if (data == null){
+ MessageView error = new MessageView(41274, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ Vector<LogFileData> logfiles = data.logFiles;
+ if (logfiles == null){
+ MessageView error = new MessageView(41275, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+
+ /*
+ * get cluster status
+ */
+ ClusterData cd = framework.getClusterData();
+
+ if (cd == null){
+ MessageView error = new MessageView(41276, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico"/>
+ <title>Log - HA -</title>
+ </head>
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+ <div id="content">
+
+ <h1>Log - HA (Heartbeat2) -</h1>
+ <%
+ if ( (message != null) && (errorMessage != null) ) {
+ %>
+ <p class="<%=resultJudge %>">[<%=category%>-<%=errorNumber%>]</p>
+ <p class="<%=resultJudge %>"><%=errorMessage%></p>
+ <%
+ }
+ %>
+
+ <h2> Download Log File</h2>
+ <h4>Please select the following list you would like to download the log file. </h4>
+
+ <table class="infotable" cellspacing="0">
+
+ <tr>
+ <th>LogFileName</th><th>LastUpdate</th><th>FileSize(byte)</th>
+ </tr>
+
+ <%
+ SimpleDateFormat dfm = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
+ NumberFormat num = NumberFormat.getInstance();
+ Iterator<LogFileData> i = logfiles.iterator();
+
+ while ( i.hasNext() ){
+ LogFileData log = (LogFileData) i.next();
+
+ if ( log != null && log.fileName != null){
+ out.println("<tr>");
+ out.println("<td>");
+ out.println("<a href=\"LogOutputServlet?type=" + LogCategorySet.HA + "&log=" + log.fileName + "\">" + log.fileName + "</a>");
+ out.println("</td>");
+ out.println("<td class=\"center\">" + dfm.format(log.time) + "</td>");
+ out.println("<td class=\"right\">" + num.format(log.size) + "</td>");
+ out.println("</tr>");
+ }
+ }
+ %>
+ </table>
+
+ </div>
+ </body>
+</html>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*, java.util.*,
+ java.text.SimpleDateFormat,java.text.NumberFormat"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41277, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+ String resultJudge = "success";
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ if ( errorNumber >= ErrNo.ERRORNUMBER )
+ resultJudge = "error";
+ }
+
+ /*
+ * get command message
+ */
+ MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE);
+ String commandMessage = "";
+ int commandNumber = 0;
+ String commandCategory = "";
+ String commandJudge = "success";
+ if (commandmessage != null) {
+ commandMessage = commandmessage.getMessage();
+ commandNumber = commandmessage.getErrno();
+ commandCategory = commandmessage.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ if ( commandNumber >= ErrNo.ERRORNUMBER )
+ commandJudge = "error";
+ }
+
+ /*
+ * get lb_log info
+ */
+ L7guiFramework framework = new L7guiFramework();
+ LogData logdata = framework.getLogData();
+ if (logdata == null){
+ MessageView error = new MessageView(41278, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ LogSet lbdata = logdata.lbLog;
+ if (lbdata == null){
+ MessageView error = new MessageView(41279, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ Vector<LogFileData> lblogfiles = lbdata.logFiles;
+ if (lblogfiles == null){
+ MessageView error = new MessageView(41280, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ HashMap<LogData.LogCategory, LogData.LogLevel> lblogcategoryset = lbdata.logLevel;
+ if (lblogcategoryset == null){
+ MessageView error = new MessageView(41281, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get cluster status
+ */
+ ClusterData cd = framework.getClusterData();
+ if (cd == null){
+ MessageView error = new MessageView(41282, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+ %>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico"/>
+ <title>Log - Load balancer (l7vsd) -</title>
+</head>
+
+<body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+ <div id="content">
+
+ <h1>Log - Load balancer (l7vsd) -</h1>
+ <%
+ if ( (message != null ) && (errorMessage != null) ) {
+ %>
+
+ <p class="<%=resultJudge %>">[<%=category%>-<%=errorNumber%>]</p>
+ <p class="<%=resultJudge %>"><%=errorMessage%></p>
+
+ <%
+ } else if ( (commandmessage != null) && (commandMessage != null) ) {
+ %>
+ <p class="<%=commandJudge %>">[<%=commandCategory%>-<%=commandNumber%>]</p>
+ <p class="<%=commandJudge %>"><%=commandMessage%></p>
+ <%
+ }
+ %>
+
+ <h2>Download Log file</h2>
+ <h4>Please select the following log file you would like to download.</h4>
+
+ <table class="infotable" cellspacing="0">
+ <tr>
+ <th>LogFileName</th><th>LastUpdate</th><th>FileSize(byte)</th>
+ </tr>
+<%
+ SimpleDateFormat dfm = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
+ NumberFormat num = NumberFormat.getInstance();
+ Iterator<LogFileData> i = lblogfiles.iterator();
+
+ while ( i.hasNext() ){
+ LogFileData log = (LogFileData) i.next();
+ if ( log != null && log.fileName != null){
+ out.println("<tr>");
+ out.println("<td>");
+ out.println("<a href=\"LogOutputServlet?type=" + LogCategorySet.L7VSD + "&log=" + log.fileName + "\">" + log.fileName + "</a>");
+ out.println("</td>");
+ out.println("<td class=\"center\">" + dfm.format(log.time) + "</td>");
+ out.println("<td class=\"right\">" + num.format(log.size) + "</td>");
+ out.println("</tr>");
+ }
+ }
+%>
+ </table>
+
+ <br />
+
+ <h2>Change Log Level</h2>
+ <h4>Please select log level of you would like to change.</h4>
+
+ <form method="post" action="LogLevelServlet" name="log_lb">
+ <input type="hidden" name="type" value="<%=LogCategorySet.L7VSD %>">
+ <table class="infotable" cellspacing="0">
+ <tr>
+ <th>Category</th><th>Level</th>
+ </tr>
+ <%
+ TreeSet<LogData.LogCategory> tree = new TreeSet<LogData.LogCategory>(lblogcategoryset.keySet());
+ Iterator<LogData.LogCategory> it = tree.iterator();
+ while (it.hasNext()) {
+ LogData.LogCategory logcategory = (LogData.LogCategory) it.next();
+ if (logcategory != null){
+ %>
+ <tr>
+ <td><%= logcategory %></td>
+ <td>
+ <select id="<%= logcategory %>" name="<%= logcategory %>">
+ <option value="<%=LogData.LogLevel.NONE %>"<%
+ if ( lblogcategoryset.get(logcategory) == LogData.LogLevel.NONE)
+ out.print(" selected");
+ %>></option>
+ <option value="<%=LogData.LogLevel.DEBUG %>"<%
+ if ( lblogcategoryset.get(logcategory) == (LogData.LogLevel.DEBUG)) {
+ out.print(" selected");
+ }
+ %>>DEBUG</option>
+ <option value="<%=LogData.LogLevel.INFO %>"<%
+ if ( lblogcategoryset.get(logcategory) == (LogData.LogLevel.INFO)){
+ out.print(" selected");
+ }
+ %>>INFO</option>
+ <option value="<%=LogData.LogLevel.ERROR %>"<%
+ if (lblogcategoryset.get(logcategory) == (LogData.LogLevel.ERROR)){
+ out.print(" selected");
+ }
+ %>>ERROR</option>
+ <option value="<%=LogData.LogLevel.WARN %>"<%
+ if ( lblogcategoryset.get(logcategory) == (LogData.LogLevel.WARN)){
+ out.print(" selected");
+ }
+ %>>WARN</option>
+ <option value="<%=LogData.LogLevel.FATAL %>"<%
+ if ( lblogcategoryset.get(logcategory) == (LogData.LogLevel.FATAL)){
+ out.print(" selected");
+ }
+ %>>FATAL</option>
+ </select>
+ </td>
+ </tr>
+ <%
+ }
+ }
+ %>
+ </table>
+
+ <br>
+ <input type="submit" name="button" value="<%= ButtonMode.APPLY %>" onClick="return confirm(log_lb_apply)" />
+
+
+ <input type="submit" name="button" value="<%= ButtonMode.SAVE %>" onClick="return confirm(log_lb_save)" />
+ <%
+ if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) {
+ %>
+ <input type="submit" name="button" value="<%= ButtonMode.SAVESYNC %>" onClick="return confirm(log_lb_savesync)" />
+ <%
+ }
+ %>
+ </form>
+
+ </div>
+ </body>
+</html>
\ No newline at end of file
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41283,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get sessionTrans
+ */
+ SessionTransData sessionTrans = (SessionTransData) session
+ .getAttribute(SessionKeys.PAGE_TRANSDATA);
+ String successpage = "";
+ String failpage = "";
+ if (sessionTrans == null) {
+ MessageView error = new MessageView(41284, LogCategorySet.GUI_LOG,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ successpage = sessionTrans.destURI;
+ failpage = sessionTrans.errorURI;
+ if ((successpage == null) || (failpage == null)) {
+ MessageView error = new MessageView(41285, LogCategorySet.GUI_LOG,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get thread status
+ */
+ String threadStatus = (String) session
+ .getAttribute(SessionKeys.THREAD_STATUS);
+ if (threadStatus == null) {
+ MessageView error = new MessageView(41286, LogCategorySet.GUI_LOG,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) {
+ response.sendRedirect(successpage);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) {
+ //
+ } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) {
+ response.sendRedirect(failpage);
+ return;
+ } else {
+ MessageView error = new MessageView(41287, LogCategorySet.GUI_LOG,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get sourcepage
+ */
+ String logname = "";
+ String sourcepage = "";
+ sourcepage = sessionTrans.sourceURI;
+
+ if (sourcepage == null) {
+ MessageView error = new MessageView(41288, LogCategorySet.GUI_LOG,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ if (sourcepage.equals("log_lb.jsp")) {
+ logname = "Load balancer";
+ } else if (sourcepage.equals("log_adm.jsp")) {
+ logname = "Admin command";
+ } else if (sourcepage.equals("log_snmp.jsp")) {
+ logname = "SNMP Agent";
+ } else if (sourcepage.equals("log_gui.jsp")) {
+ logname = "GUI";
+ } else if (sourcepage.equals("log_sync.jsp")) {
+ logname = "Sync Resource";
+ } else {
+ MessageView error = new MessageView(41289, LogCategorySet.GUI_LOG,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <meta http-equiv="refresh" content="<%= RedirectPages.REFRESH_TIME %>" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+
+ <link rel="stylesheet" type="text/css" href="l7gui_basic_style.css" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Changing Log Level</title>
+</head>
+
+<body>
+<h1 class="title">Changing Log Level</h1>
+<h2>Please wait.</h2>
+
+</body>
+</html>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*, java.util.*,
+ java.text.SimpleDateFormat,java.text.NumberFormat"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ if (session.isNew()) {
+ MessageView error = new MessageView(41290, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+ String resultJudge = "success";
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ if ( errorNumber >= ErrNo.ERRORNUMBER )
+ resultJudge = "error";
+ }
+
+ /*
+ * get command message
+ */
+ MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE);
+ String commandMessage = "";
+ int commandNumber = 0;
+ String commandCategory = "";
+ String commandJudge = "success";
+ if (commandmessage != null) {
+ commandMessage = commandmessage.getMessage();
+ commandNumber = commandmessage.getErrno();
+ commandCategory = commandmessage.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ if ( commandNumber >= ErrNo.ERRORNUMBER )
+ commandJudge = "error";
+ }
+
+ /*
+ * get snmp_log info
+ */
+ L7guiFramework framework = new L7guiFramework();
+ LogData logdata = framework.getLogData();
+
+ if (logdata == null){
+ MessageView error = new MessageView(41291, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ LogSet data = logdata.snmpLog;
+
+ if (data == null){
+ MessageView error = new MessageView(41292, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ Vector<LogFileData> logfiles = data.logFiles;
+ if (logfiles == null){
+ MessageView error = new MessageView(41293, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ HashMap<LogData.LogCategory, LogData.LogLevel> logcategoryset = data.logLevel;
+ if (logcategoryset == null){
+ MessageView error = new MessageView(41294, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get cluster status
+ */
+ ClusterData cd = framework.getClusterData();
+
+ if (cd == null){
+ MessageView error = new MessageView(41295, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico"/>
+ <title>Log - SNMPAgent -</title>
+ </head>
+
+
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+ <div id="content">
+
+ <h1>Log - SNMPAgent -</h1>
+ <%
+ if ( (message != null ) && (errorMessage != null) ) {
+ %>
+
+ <p class="<%=resultJudge %>">[<%=category%>-<%=errorNumber%>]</p>
+ <p class="<%=resultJudge %>"><%=errorMessage%></p>
+
+ <%
+ } else if ( (commandmessage != null) && (commandMessage != null) ) {
+ %>
+ <p class="<%=commandJudge %>">[<%=commandCategory%>-<%=commandNumber%>]</p>
+ <p class="<%=commandJudge %>"><%=commandMessage%></p>
+ <%
+ }
+ %>
+
+ <h2> Download Log File</h2>
+ <h4>Please select the following list you would like to download the log file. </h4>
+
+ <table class="infotable" cellspacing="0">
+
+ <tr>
+ <th>LogFileName</th><th>LastUpdate</th><th>FileSize(byte)</th>
+ </tr>
+
+ <%
+ SimpleDateFormat dfm = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
+ NumberFormat num = NumberFormat.getInstance();
+ Iterator<LogFileData> i = logfiles.iterator();
+
+ while ( i.hasNext() ){
+ LogFileData log = (LogFileData) i.next();
+
+ if ( log != null && log.fileName != null){
+ out.println("<tr>");
+ out.println("<td>");
+ out.println("<a href=\"LogOutputServlet?type=" + LogCategorySet.SNMPAGENT + "&log=" + log.fileName + "\">" + log.fileName + "</a>");
+ out.println("</td>");
+ out.println("<td class=\"center\">" + dfm.format(log.time) + "</td>");
+ out.println("<td class=\"right\">" + num.format(log.size) + "</td>");
+ out.println("</tr>");
+ }
+ }
+ %>
+
+ </table>
+
+
+ <br />
+
+ <h2>Change Log Level</h2>
+ <h4>Please select log level you would like to change.</h4>
+
+ <form method="post" action="LogLevelServlet" name="log_snmp">
+ <input type="hidden" name="type" value="<%=LogCategorySet.SNMPAGENT %>">
+ <table class="infotable" cellspacing="0">
+
+ <tr>
+ <th>Category</th><th>Level</th>
+ </tr>
+
+ <%
+ TreeSet<LogData.LogCategory> tree = new TreeSet<LogData.LogCategory>(logcategoryset.keySet());
+ Iterator<LogData.LogCategory> it = tree.iterator();
+
+ while (it.hasNext()) {
+ LogData.LogCategory logcategory = (LogData.LogCategory) it.next();
+
+ if (logcategory != null){
+ %>
+ <tr>
+ <td><%= logcategory %></td>
+ <td>
+ <select id="<%= logcategory %>" name="<%= logcategory %>">
+ <option value="<%=LogData.LogLevel.NONE %>"<%
+ if ( logcategoryset.get(logcategory) == LogData.LogLevel.NONE)
+ out.print(" selected");
+ %>></option>
+ <option value="<%=LogData.LogLevel.DEBUG %>"<%
+ if ( logcategoryset.get(logcategory) == (LogData.LogLevel.DEBUG)) {
+ out.print(" selected");
+ }
+ %>>DEBUG</option>
+ <option value="<%=LogData.LogLevel.INFO %>"<%
+ if ( logcategoryset.get(logcategory) == (LogData.LogLevel.INFO)){
+ out.print(" selected");
+ }
+ %>>INFO</option>
+ <option value="<%=LogData.LogLevel.ERROR %>"<%
+ if (logcategoryset.get(logcategory) == (LogData.LogLevel.ERROR)){
+ out.print(" selected");
+ }
+ %>>ERROR</option>
+ <option value="<%=LogData.LogLevel.WARN %>"<%
+ if ( logcategoryset.get(logcategory) == (LogData.LogLevel.WARN)){
+ out.print(" selected");
+ }
+ %>>WARN</option>
+ <option value="<%=LogData.LogLevel.FATAL %>"<%
+ if ( logcategoryset.get(logcategory) == (LogData.LogLevel.FATAL)){
+ out.print(" selected");
+ }
+ %>>FATAL</option>
+ </select>
+ </td>
+ </tr>
+ <%
+ }
+ }
+ %>
+ </table>
+
+ <br>
+ <input type="submit" name="button" value="<%= ButtonMode.APPLY %>" onClick="return confirm(log_snmp_apply)" />
+
+ <input type="submit" name="button" value="<%= ButtonMode.SAVE %>" onClick="return confirm(log_snmp_save)" />
+ <%
+ if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) {
+ %>
+ <input type="submit" name="button" value="<%= ButtonMode.SAVESYNC %>" onClick="return confirm(log_snmp_savesync)" />
+ <%
+ }
+ %>
+ </form>
+
+ </div>
+ </body>
+</html>
\ No newline at end of file
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*, java.util.*,
+ java.text.SimpleDateFormat,java.text.NumberFormat"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%
+ /*
+ * check session
+ */
+ if (session.isNew()) {
+ MessageView error = new MessageView(41296, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+ String resultJudge = "success";
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ if ( errorNumber >= ErrNo.ERRORNUMBER )
+ resultJudge = "error";
+ }
+
+ /*
+ * get command message
+ */
+ MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE);
+ String commandMessage = "";
+ int commandNumber = 0;
+ String commandCategory = "";
+ if (commandmessage != null) {
+ commandMessage = commandmessage.getMessage();
+ commandNumber = commandmessage.getErrno();
+ commandCategory = commandmessage.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ /*
+ * get sync_log info
+ */
+ L7guiFramework framework = new L7guiFramework();
+ LogData logdata = framework.getLogData();
+
+ if (logdata == null){
+ MessageView error = new MessageView(41297, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ LogSet data = logdata.syncLog;
+
+ if (data == null){
+ MessageView error = new MessageView(41298, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ Vector<LogFileData> logfiles = data.logFiles;
+ if (logfiles == null){
+ MessageView error = new MessageView(41299, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ HashMap<LogData.LogCategory, LogData.LogLevel> logcategoryset = data.logLevel;
+ if (logcategoryset == null){
+ MessageView error = new MessageView(41300, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get cluster status
+ */
+ ClusterData cd = framework.getClusterData();
+
+ if (cd == null){
+ MessageView error = new MessageView(41301, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ }
+
+ /*
+ * get log4j properties data
+ */
+ Enumeration<Logger> loggers = (Enumeration<Logger>) Logger.getRootLogger().getLoggerRepository().getCurrentLoggers();
+ TreeMap<String, String> levelMap = new TreeMap<String, String>();
+ while (loggers.hasMoreElements()) {
+ Logger logger = loggers.nextElement();
+ if (logger.getLevel() != null)
+ levelMap.put(logger.getName(), logger.getLevel().toString());
+ else if (Logger.getRootLogger().getLevel() != null)
+ levelMap.put(logger.getName(), Logger.getRootLogger().getLevel().toString());
+ else
+ levelMap.put(logger.getName(), null);
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<%@page import="org.apache.log4j.Logger"%>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico"/>
+ <title>Log - Sync Resource -</title>
+ </head>
+
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+ <div id="content">
+
+ <h1>Log - Sync Resource -</h1>
+ <%
+ if ( (message != null) && (errorMessage != null) ) {
+ %>
+ <p class="<%=resultJudge %>">[<%=category%>-<%=errorNumber%>]</p>
+ <p class="<%=resultJudge %>"><%=errorMessage%></p>
+ <%
+ }
+ %>
+
+ <h2> Download Log File</h2>
+ <h4>Please select the following list you would like to download the log file. </h4>
+
+ <table class="infotable" cellspacing="0">
+
+ <tr>
+ <th>LogFileName</th><th>LastUpdate</th><th>FileSize(byte)</th>
+ </tr>
+
+ <%
+ SimpleDateFormat dfm = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
+ NumberFormat num = NumberFormat.getInstance();
+ Iterator<LogFileData> i = logfiles.iterator();
+ while ( i.hasNext() ){
+ LogFileData log = (LogFileData) i.next();
+
+ if ( log != null && log.fileName != null){
+ out.println("<tr>");
+ out.println("<td>");
+ out.println("<a href=\"LogOutputServlet?type=" + LogCategorySet.SYNC + "&log=" + log.fileName + "\">" + log.fileName + "</a>");
+ out.println("</td>");
+ out.println("<td class=\"center\">" + dfm.format(log.time) + "</td>");
+ out.println("<td class=\"right\">" + num.format(log.size) + "</td>");
+ out.println("</tr>");
+ }
+ }
+ %>
+ </table>
+
+ <br />
+
+ <h2>Current Log Level</h2>
+
+ <form method="post" action="LogLevelServlet" name="log_sync">
+ <input type="hidden" name="type" value="<%=LogCategorySet.SYNC %>">
+ <table class="infotable" cellspacing="0">
+
+ <tr>
+ <th>Category</th><th>Level</th>
+ </tr>
+ <%
+ Iterator<String> it = levelMap.keySet().iterator();
+ while (it.hasNext()) {
+ String cat = it.next();
+ if (! cat.matches("^l7sync.*$"))
+ continue;
+ %>
+ <tr>
+ <td><%= cat %></td>
+ <td><%= levelMap.get(cat) %></td>
+ </tr>
+ <%
+ }
+ %>
+ </table>
+
+ </form>
+
+ </div>
+ </body>
+</html>
\ No newline at end of file
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*,java.util.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41302,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+
+ /*
+ * check snmpAgent status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ SnmpAgentData snmp = framework.getSnmpAgentData();
+ if (snmp == null) {
+ MessageView error = new MessageView(41303,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ }
+
+ /*
+ * get cluster status
+ */
+
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41304,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+
+<title>Log Top</title>
+
+</head>
+<body class="normal">
+<jsp:include page="menu.jsp" flush="false" />
+
+<div id="content">
+
+<h1>Log Info</h1>
+
+<h2>Log List</h2>
+<h4>Please select one of the following logs that you would like to download or change log level.</h4><br />
+
+<h3>- <a href="log_lb.jsp">Load balancer (l7vsd)</a></h3>
+<h3>- <a href="log_adm.jsp">Admin command (l7vsadm)</a></h3>
+<h3>- <a href="log_directord.jsp">Moniter RealServer (l7directord)</a></h3>
+<% if (snmp.status == SnmpAgentStatus.CONNECTING){
+%>
+<h3>- <a href="log_snmp.jsp">SNMPAgent (l7agent)</a></h3>
+<%
+}
+%>
+<h3>- <a href="log_gui.jsp">GUI (l7gui)</a></h3>
+<%
+ if (cd.self_status == ClusterStatus.ACTIVE
+ || cd.self_status == ClusterStatus.STANDBY) {
+%>
+
+ <h3>- <a href="log_sync.jsp">Sync Resource (l7sync)</a></h3>
+ <h3>- <a href="log_ha.jsp">Cluster</a></h3>
+<%
+}
+%>
+
+</div>
+</body>
+</html>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*, java.util.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
+%>
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41305, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get cluster status and fix css seat
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41306, LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+ /*
+ * in case : sessionTimeout == null(Adm Command Normal)
+ * get save status & sync status
+ */
+
+ /*
+ * Adm timeout status
+ */
+ Parameter param = Parameter.getInstance();
+ if (param == null){
+ MessageView error = new MessageView(41307, LogCategorySet.GUI_START_STOP,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ String sessionTimeout = param.getValue(Parameter.L7VSADM_TIMEOUT_FLAG);
+
+ boolean saveState = false;
+ String logSaveState = (String)session.getAttribute(SessionKeys.LOG_SAVE_STATE);
+ String vsSaveState = (String)session.getAttribute(SessionKeys.VS_SAVE_STATE);
+
+ int syncState = 0;
+ String logSyncState = null;
+ String vsSyncState = null;
+ String monitorSyncState = null;
+ String repSyncState = null;
+ String snmpSyncState = null;
+ String guiSyncState = null;
+
+ String legendInfo = null;
+
+ if ( sessionTimeout == null ) {
+ /*
+ * get save status
+ */
+
+ if ( (logSaveState == null) || (vsSaveState == null) ){
+ MessageView error = new MessageView(41308, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ if ((logSaveState.equals(SessionKeys.SAVE)) && (vsSaveState.equals(SessionKeys.SAVE))){
+ saveState = true;
+ }
+
+
+ /*
+ * in case : ACT or SBY get sync status
+ */
+ if ( (cd.self_status == ClusterStatus.ACTIVE) || (cd.self_status == ClusterStatus.STANDBY) ){
+ syncState = 1;
+ logSyncState = (String)session.getAttribute(SessionKeys.LOG_SYNC_STATE);
+ vsSyncState = (String)session.getAttribute(SessionKeys.VS_SYNC_STATE);
+ monitorSyncState = (String)session.getAttribute(SessionKeys.MONITOR_SYNC_STATE);
+ repSyncState = (String)session.getAttribute(SessionKeys.REP_SYNC_STATE);
+ snmpSyncState = (String)session.getAttribute(SessionKeys.SNMP_SYNC_STATE);
+ guiSyncState = (String)session.getAttribute(SessionKeys.GUI_SYNC_STATE);
+
+ if ( (logSyncState == null) || (vsSyncState == null)
+ || (monitorSyncState == null ) || (repSyncState == null )
+ || (snmpSyncState == null ) || (guiSyncState == null) ){
+
+ MessageView error = new MessageView(41309, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ if ( (logSyncState.equals(SessionKeys.SYNC)) && (vsSyncState.equals(SessionKeys.SYNC))
+ && (monitorSyncState.equals(SessionKeys.SYNC)) && (repSyncState.equals(SessionKeys.SYNC))
+ && (snmpSyncState.equals(SessionKeys.SYNC)) && (guiSyncState.equals(SessionKeys.SYNC)) ){
+
+ syncState = 2;
+ }
+ }
+
+
+ if ( (cd.self_status == ClusterStatus.ACTIVE) || (cd.self_status == ClusterStatus.STANDBY) ){
+ if ( saveState == true && syncState == 1 ){
+ legendInfo = "No Sync Info";
+ }
+ else if ( saveState == false && syncState == 1 ){
+ legendInfo = "No Sync & No Save Info";
+ }
+ else if ( saveState == false && syncState == 2 ){
+ legendInfo = "No Save Info";
+ }
+ }
+ else {
+ if (saveState == false ){
+ legendInfo = "No Save Info";
+ }
+ }
+ }
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Check Logout</title>
+ </head>
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+
+ <div id="content">
+
+ <h1>Check Logout </h1>
+ <form method="post" action="logout_success.jsp">
+ <%
+ if ( sessionTimeout == null ) {
+ if ( legendInfo != null ){
+ %>
+ <fieldset>
+ <legend><%=legendInfo %></legend>
+ <table class="status">
+ <%
+ if ( saveState == false ){
+ %>
+ <tr>
+ <th>
+ <label for="noSaveCategory">No Save Category</label>
+ </th>
+ <td>
+ <%
+ if ( logSaveState.equals(SessionKeys.NO_SAVE) )
+ out.println("<p class=\"text\"> Log </p>");
+ if ( vsSaveState.equals(SessionKeys.NO_SAVE ) )
+ out.println("<p class=\"text\"> Service </p>");
+ %>
+ </td>
+ </tr>
+ <%
+ }
+ %>
+ <%
+ if ( syncState == 1){
+ %>
+ <tr>
+ <th>
+ <label for="noSyncCategory">No Sync Category</label>
+ </th>
+ <td>
+ <%
+ if ( logSyncState.equals(SessionKeys.NO_SYNC) )
+ out.println("<p class=\"text\"> Log </p>");
+ if ( monitorSyncState.equals(SessionKeys.NO_SYNC ) )
+ out.println("<p class=\"text\"> Monitor </p>");
+ if ( vsSyncState.equals(SessionKeys.NO_SYNC ) )
+ out.println("<p class=\"text\"> Service </p>");
+ if ( repSyncState.equals(SessionKeys.NO_SYNC ) )
+ out.println("<p class=\"text\"> Replication </p>");
+ if ( snmpSyncState.equals(SessionKeys.NO_SYNC ) )
+ out.println("<p class=\"text\"> SNMPAgent </p>");
+ if ( guiSyncState.equals(SessionKeys.NO_SYNC ) )
+ out.println("<p class=\"text\"> GUI </p>");
+ %>
+ </td>
+ </tr>
+ <%
+ }
+ %>
+ </table>
+ </fieldset>
+ <%
+ }
+ }
+ %>
+
+ <h2>Logout OK?</h2>
+ <input type="submit" name="button" value="<%=ButtonMode.YES %>" onClick="return confirm(logout)" />
+ </form>
+
+ </div>
+ </body>
+</html>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*, java.util.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
+%>
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41310, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * invalid session
+ */
+ session.invalidate();
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="l7gui_basic_style.css" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Logout success</title>
+ </head>
+
+ <body class="normal">
+ <h2>Logout success.</h2>
+ <h2>Good-Bye.</h2>
+
+ <h3>
+ <a href="index.jsp"> Login</a>
+ </h3>
+
+ </body>
+</html>
+
\ No newline at end of file
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*, org.ultramonkey.l7.controller.*, org.ultramonkey.l7.view.*,
+ java.net.InetAddress, java.net.UnknownHostException,java.util.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
+%>
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41311, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41312, LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get UserNmae
+ */
+ UserData currentUser = (UserData) session.getAttribute(SessionKeys.LOGIN_SESSION);
+ if (currentUser == null) {
+ MessageView error = new MessageView(41313, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ String userName = currentUser.userName;
+ if (userName == null){
+ MessageView error = new MessageView(41314, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+
+ /*
+ * get host name
+ */
+ InetAddress hostName = null;
+ try {
+ hostName = InetAddress.getLocalHost();
+ }
+ catch(UnknownHostException e){
+ hostName =null;
+ }
+
+ /*
+ * get save status
+ */
+ boolean saveState = false;
+ String logSaveState = (String)session.getAttribute(SessionKeys.LOG_SAVE_STATE);
+ String vsSaveState = (String)session.getAttribute(SessionKeys.VS_SAVE_STATE);
+
+ if ( (logSaveState == null) || (vsSaveState == null) ){
+ MessageView error = new MessageView(41315, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ if ((logSaveState.equals(SessionKeys.SAVE)) && (vsSaveState.equals(SessionKeys.SAVE))){
+ saveState = true;
+ }
+
+
+ /*
+ * get sync status
+ */
+ boolean syncState = false;
+ String logSyncState = (String)session.getAttribute(SessionKeys.LOG_SYNC_STATE);
+ String vsSyncState = (String)session.getAttribute(SessionKeys.VS_SYNC_STATE);
+ String monitorSyncState = (String)session.getAttribute(SessionKeys.MONITOR_SYNC_STATE);
+ String repSyncState = (String)session.getAttribute(SessionKeys.REP_SYNC_STATE);
+ String snmpSyncState = (String)session.getAttribute(SessionKeys.SNMP_SYNC_STATE);
+ String guiSyncState = (String)session.getAttribute(SessionKeys.GUI_SYNC_STATE);
+
+ if ( (logSyncState.equals(SessionKeys.SYNC)) && (vsSyncState.equals(SessionKeys.SYNC))
+ && (monitorSyncState.equals(SessionKeys.SYNC)) && (repSyncState.equals(SessionKeys.SYNC))
+ && (snmpSyncState.equals(SessionKeys.SYNC)) && (guiSyncState.equals(SessionKeys.SYNC)) ){
+ syncState = true;
+ }
+
+ /*
+ * Adm timeout status
+ */
+ Parameter param = Parameter.getInstance();
+ if (param == null){
+ MessageView error = new MessageView(41316, LogCategorySet.GUI_START_STOP,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ String sessionTimeout = param.getValue(Parameter.L7VSADM_TIMEOUT_FLAG);
+
+ /*
+ * get L7vsAdmData (SNMPAgent)
+ */
+ L7vsAdmData admData = framework.getAdmData();
+ SnmpAgentStatus snmpStatus = SnmpAgentStatus.NON_CONNECTING;
+ if (admData != null) {
+ snmpStatus = admData.snmpStatus;
+ }
+
+ /*
+ * get L7vsAdmData (Replication)
+ */
+ ReplicationStatus repStatus = ReplicationStatus.SINGLE;
+ if (admData != null) {
+ repStatus = admData.replicationMode;
+ }
+
+ /*
+ * get user info
+ */
+ UserManager user = UserManager.getInstance();
+ Vector<UserData> userList;
+ try {
+ userList = user.getUserList();
+ }
+ catch(Exception e){
+ MessageView error = new MessageView(41317, LogCategorySet.GUI_IO_FILE,
+ Message.READ_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ if ( userList == null ){
+ MessageView error = new MessageView(41318, LogCategorySet.GUI_IO_FILE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ int userCount = userList.size();
+%>
+
+<div id="sidebar">
+
+
+<a href="top.jsp">
+<img class="top" src="images/ultraMonkey-L7rogo.gif" width="207" height="27" alt="UltraMonkey-L7 logo" /></a>
+<h4 class="menu">Host Name :
+<%
+ if (hostName != null){
+ out.println(hostName.getHostName());
+ }
+ else {
+ out.println("Unknown Host Name");
+ }
+%>
+</h4>
+
+<h4 class="menu">UserID : <%= userName %></h4>
+
+<%
+ if ( (cd.self_status == ClusterStatus.ACTIVE) || (cd.self_status == ClusterStatus.STANDBY ) ){
+ int localPort = request.getLocalPort();
+ String context = request.getContextPath();
+ String peerIP = cd.other_ip;
+ String peerAddress = "http://" + peerIP + ":" + localPort + context + "/index.jsp" ;
+
+ if(cd.self_status == ClusterStatus.ACTIVE){
+%>
+ <h4 class="menu">Self Node Status : <%= cd.self_status %></h4>
+ <input class="topeer" type="image" align="middle" id="toSby" name="toSby" src="images/toSby.gif" onClick="window.open('<%=peerAddress %>')">
+<%
+ }
+ else {
+%>
+ <h4 class="menu">Self Node Status : <%= cd.self_status %></h4>
+ <input class="topeer" type="image" align="middle" id="toAct" name="toAct" src="images/toAct.gif" onClick="window.open('<%=peerAddress %>')">
+<%
+ }
+ }
+
+ if ( sessionTimeout == null ) {
+ if ( saveState == false){
+%>
+ <h4 class="note">
+ <img src="images/exclamation3.gif" alt="Caution!!" width="16" height="14" align="middle">
+ No Save</h4>
+<%
+ }
+
+ if ( (cd.self_status == ClusterStatus.ACTIVE ) || (cd.self_status == ClusterStatus.STANDBY) ){
+ if ( syncState == false ){
+%>
+ <h4 class="note">
+ <img src="images/exclamation3.gif" alt="Caution!!" width="16" height="14" align="middle">
+ No Sync</h4>
+<%
+ }
+ }
+ }
+%>
+
+<br />
+<br />
+
+
+<h2 class="menu">
+<img src="images/Monkey.gif" alt="UltraMonkey-L7 graffic" width="30" height="30" align="middle">
+MENU
+<img src="images/Monkey.gif" alt="UltraMonkey-L7 graffic" width="30" height="30" align="middle">
+</h2>
+
+<table class="menu">
+
+<tr>
+ <td></td>
+ <td><a href="top.jsp">Top</a></td>
+</tr>
+
+<%
+ if ( (sessionTimeout == null) &&
+ ( (cd.self_status.equals(ClusterStatus.ACTIVE)) || (cd.self_status.equals(ClusterStatus.SINGLE)) ) ){
+%>
+<tr>
+ <td>
+ <img class="icon" src="images/plus.gif" onclick="openTree('virtualservice', this)" />
+ </td>
+ <td>
+ <a href="um7state_info.jsp">VirtualService</a><br />
+ <div id="virtualservice" style="display:none">
+ <a href="vs_add.jsp" class="sub">Add</a>
+ </div>
+ </td>
+</tr>
+<%
+ }
+ if (sessionTimeout == null){
+%>
+<tr>
+ <td>
+ <img class="icon" src="images/plus.gif" onclick="openTree('monitor', this)" />
+ </td>
+ <td>
+ <a href="monitor_info.jsp" >Monitor</a><br />
+ <div id="monitor" style="display:none">
+ <a href="monitor_modify.jsp" class="sub">Modify</a>
+ </div>
+ </td>
+</tr>
+<%
+ }
+ if ( sessionTimeout == null && cd.other_ip != null ) {
+%>
+<tr>
+ <td></td>
+ <td><a href="redundant_info.jsp">Redundancy</a></td>
+</tr>
+<%
+ }
+ if ( (sessionTimeout == null) &&
+ ( repStatus != ReplicationStatus.SINGLE ) ){
+%>
+<tr>
+ <td>
+ <img class="icon" src="images/plus.gif" onclick="openTree('replication', this)" />
+ </td>
+ <td>
+ <a href="replication.jsp">Replication</a><br />
+ <div id="replication" style="display:none">
+ <a href="replication_modify.jsp" class="sub">Modify</a>
+ </div>
+ </td>
+</tr>
+<%
+ }
+ if (sessionTimeout == null){
+%>
+<tr>
+ <td></td>
+ <td><a href="save.jsp">Save Resources</a></td>
+</tr>
+<%
+ }
+ if ( (sessionTimeout == null) &&
+ ( (cd.self_status == ClusterStatus.ACTIVE ) || (cd.self_status == ClusterStatus.STANDBY) ) ){
+%>
+<tr>
+ <td></td>
+ <td><a href="sync.jsp">Sync Resources</a></td>
+</tr>
+<%
+ }
+ if ( (sessionTimeout == null) && ( snmpStatus == SnmpAgentStatus.CONNECTING ) ){
+%>
+<tr>
+ <td></td>
+ <td><a href="snmp.jsp">SNMP Agent</a></td>
+</tr>
+<%
+ }
+
+%>
+<tr>
+ <td>
+ <img class="icon" src="images/plus.gif" onclick="openTree('log', this)" />
+ </td>
+ <td>
+ <a href="log_top.jsp" >Log</a><br />
+ <div id="log" style="display:none">
+ <a href="log_lb.jsp" class="sub">Load balancer</a><br />
+ <a href="log_adm.jsp" class="sub">Admin command</a><br />
+ <a href="log_directord.jsp" class="sub">Monitor RealServer</a><br />
+ <%if ( snmpStatus == SnmpAgentStatus.CONNECTING ){
+ %>
+ <a href="log_snmp.jsp" class="sub">SNMP Agent</a><br />
+ <%
+ }
+ %>
+ <a href="log_gui.jsp" class="sub">GUI</a><br />
+ <%if ( (cd.self_status == ClusterStatus.ACTIVE) || (cd.self_status == ClusterStatus.STANDBY) ){ %>
+ <a href="log_sync.jsp" class="sub">Sync</a><br />
+ <%
+ }
+ if ( cd.self_status != ClusterStatus.SINGLE ) {
+ %>
+ <a href="log_ha.jsp" class="sub">Cluster</a>
+ <%
+ }
+ %>
+ </div>
+ </td>
+</tr>
+
+<tr>
+ <td>
+ <img class="icon" src="images/plus.gif" onclick="openTree('manageusers', this)" />
+ </td>
+ <td>
+ <a href="user_manage.jsp">Manage Users</a><br />
+ <div id="manageusers" style="display:none">
+ <%
+ if (userCount < 16){
+ %>
+ <a href="user_add.jsp" class="sub">Add</a><br />
+ <%
+ }
+ %>
+ <a href="user_modify.jsp" class="sub">Modify</a><br />
+ </div>
+
+ </td>
+</tr>
+
+<tr>
+<td> </td>
+</tr>
+<tr>
+ <td></td>
+ <td><a href="logout.jsp">Logout</a></td>
+</tr>
+
+
+</table>
+
+</div>
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*,java.util.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41319,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.RESULT_MESSAGE);
+
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+ /*
+ * get command message
+ */
+ MessageView commandmessage = (MessageView) session
+ .getAttribute(SessionKeys.COMMAND_MESSAGE);
+
+ String commandMessage = "";
+ int commandNumber = 0;
+ String commandCategory = "";
+
+ if (commandmessage != null) {
+ commandMessage = commandmessage.getMessage();
+ commandNumber = commandmessage.getErrno();
+ commandCategory = commandmessage.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ /*
+ * get DirectorData
+ */
+ L7guiFramework framework = new L7guiFramework();
+ DirectorData dd = framework.getDirectorData();
+ if (dd == null) {
+ MessageView error = new MessageView(41320,
+ LogCategorySet.GUI_IO_FILE, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get cluster status
+ */
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41321,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+
+ <title>Monitor Current Status</title>
+</head>
+
+<body class="normal">
+<jsp:include page="menu.jsp" flush="false" />
+
+<div id="content">
+
+
+<h1>Monitor Current Status</h1>
+
+<%
+if (message != null) {
+%>
+
+<p class="error">[<%=category%>-<%=errorNumber%>]</p>
+<p class="error"><%=errorMessage%></p>
+
+<%
+} else if (commandmessage != null) {
+%>
+<p class="success">[<%=commandCategory%>-<%=commandNumber%>]</p>
+<p class="success"><%=commandMessage%></p>
+<%
+}
+%>
+
+<fieldset><legend>Monitor Settings</legend>
+<table class="infotable">
+ <tr>
+ <th class="left"><label for="checkTimeOut">CheckTimeOut</label></th>
+ <td class="null">
+ <%
+ if ( (null != dd.checkTimeOut) && ("" != dd.checkTimeOut) )
+ out.print(dd.checkTimeOut + " [sec]");
+ %>
+ </td>
+ </tr>
+
+ <tr>
+ <th class="left"><label for="negotiateTimeOut">NegotiateTimeOut</label>
+ </th>
+ <td class="null">
+ <%
+ if ( (null != dd.negotiateTimeOut) && ("" != dd.negotiateTimeOut) )
+ out.print(dd.negotiateTimeOut + " [sec]");
+ %>
+ </td>
+ </tr>
+
+ <tr>
+ <th class="left"><label for="checkInterval">CheckInterval</label>
+ </th>
+ <td class="null">
+ <%
+ if ( (null != dd.checkInterval) && ("" != dd.checkInterval) )
+ out.print(dd.checkInterval + " [sec]");
+ %>
+ </td>
+ </tr>
+
+ <tr>
+ <th class="left"><label for="checkCount">CheckCount</label></th>
+ <td class="null">
+ <%
+ if ( (null != dd.checkCount) && ("" != dd.checkCount) )
+ out.print(dd.checkCount + " [time]");
+ %>
+ </td>
+ </tr>
+
+ <tr>
+ <th class="left"><label for="callback">Callback</label></th>
+ <td class="null">
+ <%
+ if (null != dd.callback)
+ out.print(dd.callback);
+ %>
+ </td>
+ </tr>
+
+ <tr>
+ <th class="left"><label for="fallback">Fallback</label></th>
+ <td class="null">
+ <%
+ if (null != dd.fallback)
+ out.print(dd.fallback);
+ %>
+ </td>
+ </tr>
+
+ <tr>
+ <th class="left"><label for="logfile">Logfile</label></th>
+ <td class="null">
+ <%
+ if (null != dd.logfile)
+ out.print(dd.logfile);
+ %>
+ </td>
+ </tr>
+
+ <tr>
+ <th class="left"><label for="execute">Execute</label></th>
+ <td class="null">
+ <%
+ if (null != dd.execute)
+ out.print(dd.execute);
+ %>
+ </td>
+ </tr>
+
+ <tr>
+ <th class="left"><label for="supervised">Supervised</label></th>
+ <td class="null">
+ <%
+ if (null != dd.supervised)
+ out.print(dd.supervised);
+ %>
+ </td>
+ </tr>
+
+ <tr>
+ <th class="left"><label for="quiescent">Quiescent</label></th>
+ <td class="null">
+ <%
+ if (null != dd.quiescent)
+ out.print(dd.quiescent);
+ %>
+ </td>
+ </tr>
+
+</table>
+</fieldset>
+
+
+<h2>Modify Monitor setting</h2>
+<h4>Please push the following button, if you would like to modify the Monitor setting.</h4>
+<form method="post" action="monitor_modify.jsp">
+ <input type="submit" value="Modify">
+</form>
+</div>
+</body>
+</html>
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*,java.util.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41322, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+ /*
+ * get validation error message
+ */
+ HashMap<String,String> errMessage = (HashMap<String,String>) session.getAttribute(SessionKeys.INVALID_MESSAGE);
+ session.setAttribute(SessionKeys.INVALID_MESSAGE, null);
+
+ /*
+ * get previous inputvalue
+ */
+ L7guiFramework framework = new L7guiFramework();
+ DirectorData dd = (DirectorData) session.getAttribute(SessionKeys.INPUT_MONITOR);
+
+ if (dd != null){
+ session.setAttribute(SessionKeys.INPUT_MONITOR, null);
+ }
+ else{
+ /*
+ * get DirectorData
+ */
+ dd = framework.getDirectorData();
+ if (dd == null){
+ MessageView error = new MessageView(41323, LogCategorySet.GUI_IO_FILE, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ }
+
+ /*
+ * get cluster status
+ */
+ ClusterData cd = framework.getClusterData();
+ if (cd == null){
+ MessageView error = new MessageView(41324, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+
+ <title>Modify Monitor Info</title>
+
+</head>
+
+<body class="normal">
+<jsp:include page="menu.jsp" flush="false" />
+
+<div id="content">
+
+<h1>Modify Monitor Setting</h1>
+
+<%
+if ( (message != null) && (errorMessage != null) ) {
+%>
+<p class="error">[<%=category%>-<%=errorNumber%>]</p>
+<p class="error"><%=errorMessage%></p>
+<%
+}
+%>
+
+
+<form method="post" action="MonitorSetServlet">
+
+<fieldset><legend>Monitor Setting</legend>
+
+<table class="status">
+ <tr>
+ <th><label for="checkTimeOut">CheckTimeOut</label></th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ){
+ invalidMessage = errMessage.get("checkTimeOut");
+ }
+ if ( null == dd.checkTimeOut ){
+ out.print("<input type=\"text\" id=\"checkTimeOut\" value=\"\" name=\"checkTimeOut\" size=\"11\" maxlength=\"11\" /> [sec]");
+ }
+ else{
+ out.print("<input type=\"text\" id=\"checkTimeOut\" value=\"" + dd.checkTimeOut + "\" name=\"checkTimeOut\" size=\"11\" maxlength=\"11\" /> [sec]");
+ }
+ if ( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">1-2147483647(sec)<br>
+ Default : 5(sec)</p>
+ </td>
+ </tr>
+ <tr>
+ <th><label for="negotiateTimeOut">NegotiateTimeOut</label></th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ){
+ invalidMessage = errMessage.get("negotiateTimeOut");
+ }
+ if ( null == dd.negotiateTimeOut ){
+ out.print("<input type=\"text\" id=\"negotiateTimeOut\" value=\"\" name=\"negotiateTimeOut\" size=\"11\" maxlength=\"11\" /> [sec]");
+ }
+ else{
+ out.print("<input type=\"text\" id=\"negotiateTimeOut\" value=\"" + dd.negotiateTimeOut + "\" name=\"negotiateTimeOut\" size=\"11\" maxlength=\"11\" /> [sec]");
+ }
+ if ( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">1-2147483647(sec)<br>
+ Default is defined by the operating system.</p>
+ </td>
+ </tr>
+ <tr>
+ <th><label for="checkInterval">CheckInterval</label></th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ){
+ invalidMessage = errMessage.get("checkInterval");
+ }
+ if ( null == dd.checkInterval ){
+ out.print("<input type=\"text\" id=\"checkInterval\" value=\"\" name=\"checkInterval\" size=\"11\" maxlength=\"11\" /> [sec]");
+ }
+ else{
+ out.print("<input type=\"text\" id=\"checkInterval\" value=\"" + dd.checkInterval + "\" name=\"checkInterval\" size=\"11\" maxlength=\"11\" /> [sec]");
+ }
+ if ( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">1-2147483647(sec)<br>
+ Default : 10(sec)</p>
+ </td>
+ </tr>
+ <tr>
+ <th><label for="checkCount">CheckCount</label></th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ){
+ invalidMessage = errMessage.get("checkCount");
+ }
+ if ( null == dd.checkCount ){
+ out.print("<input type=\"text\" id=\"checkCount\" value=\"\" name=\"checkCount\" size=\"11\" maxlength=\"11\" /> [time]");
+ }
+ else{
+ out.print("<input type=\"text\" id=\"checkCount\" value=\"" + dd.checkCount + "\" name=\"checkCount\" size=\"11\" maxlength=\"11\" /> [time]");
+ }
+ if ( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">1-2147483647(time)<br>
+ Default : 1(time)</p>
+ </td>
+ </tr>
+ <tr>
+ <th><label for="callback">Callback</label></th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ){
+ invalidMessage = errMessage.get("callback");
+ }
+ if ( null == dd.callback ){
+ out.print("<input type=\"text\" id=\"callback\" value=\"\" name=\"callback\"/>");
+ }
+ else{
+ out.print("<input type=\"text\" id=\"callback\" value=\"" + dd.callback + "\" name=\"callback\" />");
+ }
+ if ( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required"></p>
+ </td>
+ </tr>
+ <tr>
+ <th><label for="fallback">Fallback</label></th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ){
+ invalidMessage = errMessage.get("fallback");
+ }
+ if ( null == dd.fallback ){
+ out.print("<input type=\"text\" id=\"fallback\" value=\"\" name=\"fallback\"/>");
+ }
+ else{
+ out.print("<input type=\"text\" id=\"fallback\" value=\"" + dd.fallback + "\" name=\"fallback\" />");
+ }
+ if ( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required"></p>
+ </td>
+ </tr>
+ <tr>
+ <th><label for="logfile">Logfile</label></th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ){
+ invalidMessage = errMessage.get("logfile");
+ }
+ if ( null == dd.logfile ){
+ out.print("<input type=\"text\" id=\"logfile\" value=\"\" name=\"logfile\"/>");
+ }
+ else{
+ out.print("<input type=\"text\" id=\"logfile\" value=\"" + dd.logfile + "\" name=\"logfile\" />");
+ }
+ if ( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Default : /var/log/l7directord.log</p>
+ </td>
+ </tr>
+ <tr>
+ <th><label for="execute">Execute</label></th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ){
+ invalidMessage = errMessage.get("execute");
+ }
+ if ( null == dd.execute ){
+ out.print("<input type=\"text\" id=\"execute\" value=\"\" name=\"execute\"/>");
+ }
+ else{
+ out.print("<input type=\"text\" id=\"execute\" value=\"" + dd.execute + "\" name=\"execute\" />");
+ }
+ if ( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required"></p>
+ </td>
+ </tr>
+
+ <tr>
+ <th><label for="supervised">Supervised</label></th>
+ <td><select id="supervised" name="supervised">
+ <option value=""></option>
+ <option value="yes"<%
+ if ( ( null != dd.supervised ) && (dd.supervised.equals("yes")) )
+ out.print(" selected");
+ %>>Yes</option>
+ <option value="no"<%
+ if ( ( null != dd.supervised ) && (dd.supervised.equals("no")) )
+ out.print(" selected");
+ %>>No</option>
+ </select> <%
+ if ( null != errMessage ){
+ String invalidMessage = errMessage.get("supervised");
+ if ( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Default : No</p>
+ </td>
+
+ </tr>
+
+ <tr>
+ <th><label for="quiescent">Quiescent</label></th>
+ <td><select id="quiescent" name="quiescent">
+ <option value=""></option>
+ <option value="yes"<%
+ if ( ( null != dd.quiescent ) && (dd.quiescent.equals("yes")) )
+ out.print(" selected");
+ %>>Yes</option>
+ <option value="no"<%
+ if ( ( null != dd.quiescent ) && (dd.quiescent.equals("no")) )
+ out.print(" selected");
+ %>>No</option>
+ </select> <%
+ if ( null != errMessage ){
+ String invalidMessage = errMessage.get("quiescent");
+ if ( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Default : No</p>
+ </td>
+ </tr>
+</table>
+</fieldset>
+
+<br />
+
+<input type="submit" name="button" value="<%=ButtonMode.SAVE %>" onClick="return confirm(monitor_modify_save)" />
+<%
+if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) {
+%>
+<input type="submit" name="button" value="<%=ButtonMode.SAVESYNC %>" onClick="return confirm(monitor_modify_savesync)" />
+<%
+}
+%> <input type="reset" value="Reset" /></form>
+</div>
+</body>
+</html>
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41325,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get thread status
+ */
+ String threadStatus = (String) session
+ .getAttribute(SessionKeys.THREAD_STATUS);
+ if (threadStatus == null) {
+ MessageView error = new MessageView(41326,
+ LogCategorySet.GUI_MONITOR, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) {
+ // nothing to do
+ } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) {
+ response.sendRedirect(RedirectPages.MONITOR_INFO);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) {
+ response.sendRedirect(RedirectPages.MONITOR_MODIFY_NG);
+ return;
+ } else {
+ MessageView error = new MessageView(41327,
+ LogCategorySet.GUI_MONITOR, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.REFRESH_TIME %>"/>
+
+ <link rel="stylesheet" type="text/css" href="l7gui_basic_style.css" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Running Modify Monitor RealServer</title>
+</head>
+
+<body>
+
+<h1 class="title">Running Modify Monitor RealServer</h1>
+<h2>Please wait.</h2>
+
+</body>
+</html>
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41328,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.COMMAND_MESSAGE);
+
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41329,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Failed : Modify Monitor</title>
+</head>
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false" />
+
+<div id="content">
+<h1 class="title">Failed : Modify Monitor</h1>
+<h2>Monitor Info Modify Failed.</h2>
+<h2>Error Reason :</h2>
+<p class="error">[<%=category%>-<%=errorNumber%>]</p>
+<p class="error"><%=errorMessage%></p>
+
+</div>
+</body>
+</html>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%
+
+ /*
+ * check session
+ */
+ if (session.isNew()) {
+ MessageView error = new MessageView(41330, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get command message
+ */
+ MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE);
+ String commandMessage = "";
+ int commandNumber = 0;
+ String commandCategory = "";
+ if (commandmessage != null) {
+ commandMessage = commandmessage.getMessage();
+ commandNumber = commandmessage.getErrno();
+ commandCategory = commandmessage.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41331, LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ // IP CHECK
+ String selfIp = cd.self_ip;
+ String otherIp = cd.other_ip;
+
+ if ( (selfIp == null) || (otherIp == null) ){
+ MessageView error = new MessageView(41332, LogCategorySet.GUI_REDUNDANT,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%= cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico"/>
+
+ <title>Redundance</title>
+ </head>
+
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+
+ <div id="content">
+
+ <h1>Redundance</h1>
+ <% if (cd.self_status == ClusterStatus.SINGLE ){
+ %>
+ <p class="error">Cluster disabled.</p>
+ <%
+ }
+ else {
+ %>
+ <fieldset class="">
+ <legend>Current Status</legend>
+
+ <table class="infotable">
+ <tr>
+ <th class="center">
+ <label for="empty"></label>
+ </th>
+ <th class="center">
+ Self Node
+ </th>
+ <th class="center">
+ Peer Node
+ </th>
+ </tr>
+ <tr>
+ <th class="left">
+ <label for="nodeStatus">Node Status</label>
+ </th>
+ <td>
+ <%= cd.self_status %>
+ </td>
+ <td>
+ <%= cd.other_status %>
+ </td>
+ </tr>
+ <tr>
+ <th class="left">
+ <label for="realIp">Real IP Address</label>
+ </th>
+ <td>
+ <%= selfIp %>
+ </td>
+ <td>
+ <%= otherIp %>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+
+
+
+
+ <% if ( ( (cd.self_status == ClusterStatus.ACTIVE) || (cd.self_status == ClusterStatus.STANDBY) )
+ && ( (cd.other_status == ClusterStatus.ACTIVE) || (cd.other_status == ClusterStatus.STANDBY) ) ){
+ %>
+ <form method="post" action="SoRunServlet">
+ <h4>Please push the following button, if you would like to switch over.</h4><br />
+ <input type="submit" name="button" value="<%=ButtonMode.SWITCH_OVER %>" onClick="return confirm(switch_over)" />
+ </form>
+ <%
+ }
+ }
+ %>
+ </div>
+ </body>
+
+</html>
+
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*, java.util.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%
+
+ /*
+ * check session
+ */
+ if (session.isNew()) {
+ MessageView error = new MessageView(41333, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = null;
+ int errorNumber = 0;
+ String category = "";
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+
+ /*
+ * get command message
+ */
+ MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE);
+ String commandMessage = null;
+ int commandNumber = 0;
+ String commandCategory = "";
+ if (commandmessage != null) {
+ commandMessage = commandmessage.getMessage();
+ commandNumber = commandmessage.getErrno();
+ commandCategory = commandmessage.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ // get replicationData
+ L7guiFramework framework = new L7guiFramework();
+ ReplicationData rep = framework.getReplicationData();
+ ReplicationStatus repStatus = ReplicationStatus.OUT;
+ if ( null == rep ){
+ MessageView error = new MessageView(41334, LogCategorySet.GUI_IO,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ else {
+ repStatus = rep.replicationMode;
+ }
+ String printRepStatus = null;
+ String changeModeMessage = null;
+ switch (repStatus){
+ case MASTER:
+ printRepStatus = "Master Running";
+ changeModeMessage = "If you would like to stop sending Replication data, push the following button.";
+ break;
+ case SLAVE:
+ printRepStatus = "Slave Running";
+ changeModeMessage = "If you would like to stop receiving Replication data, push the following button.";
+ break;
+ case MASTER_STOP:
+ printRepStatus = "Master Stopped";
+ changeModeMessage = "If you would like to start sending Replication data, push the following button.";
+ break;
+ case SLAVE_STOP:
+ printRepStatus = "Slave Stopped";
+ changeModeMessage = "If you would like to start receiving Replication data, push the following button.";
+ break;
+ case SINGLE:
+ printRepStatus = "Replication Invalid";
+ break;
+ case OUT:
+ printRepStatus = "In Starting Replication";
+ break;
+ default :
+ MessageView error = new MessageView(41335, LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ String selfNic = rep.nic;
+ String peerIp = rep.otherNode.host;
+
+ if ( (selfNic == null) || (peerIp == null) ){
+ MessageView error = new MessageView(41336, LogCategorySet.GUI_IO_FILE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ HashMap<String, Integer> repDatainfo = rep.component;
+ Set keys = null;
+ if (repDatainfo != null){
+ keys = repDatainfo.keySet();
+ }
+
+ /*
+ * get cluster status
+ */
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41337, LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+%>
+
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%= cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico"/>
+
+ <title>Replication</title>
+
+ </head>
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+
+ <div id="content">
+
+
+ <h1>Replication</h1>
+ <%
+ if ( (message != null) && (errorMessage != null) ) {
+ %>
+
+ <p class="error">[<%=category %> - <%=errorNumber %>]</p>
+ <p class="error"><%=errorMessage %></p>
+
+ <%
+ }
+ else if ( (commandmessage != null) && (commandMessage != null) ){
+ %>
+ <p class="success">[<%=commandCategory %> - <%=commandNumber %>]</p>
+ <p class="success"><%=commandMessage %></p>
+ <%
+ }
+ %>
+
+ <h2> Replication Current Status</h2>
+
+ <form method="post" action="ReplicationModeChangeServlet" name="rep" >
+ <fieldset>
+ <legend>Replication Current Status</legend>
+ <table class="infotable" cellspacing="0">
+ <thead>
+ <tr>
+ <th>Replication Mode</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td class="center"><%=printRepStatus %></td>
+ </tr>
+ </tbody>
+ </table>
+ </fieldset>
+ <% if ( changeModeMessage != null){
+ %>
+ <h4><%=changeModeMessage %></h4>
+ <br />
+ <%
+ }
+ switch (repStatus){
+ case MASTER:
+ %>
+ <input type="submit" name="button" value="<%=ButtonMode.REP_MASTER_STOPPING %>" onClick="return confirm(replication_stop_send)" />
+ <%
+ break;
+ case SLAVE:
+ %>
+ <input type="submit" name="button" value="<%=ButtonMode.REP_SLAVE_STOPPING %>" onClick="return confirm(replication_stop_receive)" />
+ <%
+ break;
+ case MASTER_STOP:
+ %>
+ <input type="submit" name="button" value="<%=ButtonMode.REP_MASTER_RUNNING %>" onClick="return confirm(replication_start_send)" />
+ <%
+ break;
+ case SLAVE_STOP:
+ %>
+ <input type="submit" name="button" value="<%=ButtonMode.REP_SLAVE_RUNNING %>" onClick="return confirm(replication_start_receive)" />
+ <%
+ break;
+ }
+ %>
+ </form>
+
+
+ <%
+ if ( repStatus != ReplicationStatus.SINGLE ){
+ %>
+ <form method="post" action="replication_modify.jsp" name="rep_info">
+ <h2> Replication Configuration Information</h2>
+ <fieldset>
+ <legend>Replication Configuration Information</legend>
+ <table class="infotable" cellspacing="0">
+ <thead>
+ <tr>
+ <th>Self Node</th><th colspan="2">Peer Node</th><th rowspan="2">Interval</th>
+ </tr>
+ <tr>
+ <th>NIC</th><th>IP Address</th><th>Port Number</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td class="center"><%=selfNic %></td>
+ <td class="center"><%=peerIp %></td>
+ <td class="center"><%=rep.otherNode.port %></td>
+ <td class="center"><%=rep.interval %> [µsec]</td>
+ </tr>
+ </tbody>
+ </table>
+ </fieldset>
+ <h4>If you would like to modify Interval, push the following button.</h4>
+ <br />
+ <input type="submit" value="Modify" />
+ </form>
+
+ <% if (keys != null) {%>
+ <h2> Replication Data Size Information</h2>
+ <fieldset>
+ <legend>Replication Data Size Information</legend>
+ <table class="infotable" cellspacing="0">
+ <tr>
+ <%
+ for (Iterator iterator = keys.iterator(); iterator.hasNext();){
+ %>
+ <th><%=iterator.next() %></th>
+ <%
+ }
+ %>
+ </tr>
+ <tr>
+ <%
+ for (Iterator iterator = keys.iterator(); iterator.hasNext();){
+ String key = (String)iterator.next();
+ double size = ((Integer)repDatainfo.get(key)) * 480;
+ String sizeUnit = "[byte]";
+ if ( (size >= 1000) && ( size < 1000000 )){
+ size = size / 1000 ;
+ sizeUnit = "[Kbyte]";
+ }
+ else if( size >= 1000000 ){
+ size = size / 1000000 ;
+ sizeUnit = "[Mbyte]";
+ }
+ out.println("<td class=\"center\">" + size + "" + sizeUnit + "</td>");
+ }
+ %>
+ </tr>
+ </table>
+ </fieldset>
+
+ <%
+ if ( repStatus == ReplicationStatus.MASTER ){
+ %>
+ <h2> Immediate Replication</h2>
+ <form method="post" action="ReplicationRunServlet" name="rep" >
+ <h4>If you would like to execute immediate Replication, push the following button.</h4>
+ <br />
+ <input type="submit" name="button_immediate" value="<%=ButtonMode.REP_EXECUTE%>" onClick="return confirm(replication_dump)" />
+ </form>
+ <%
+ }
+ }
+ }
+ %>
+
+ </div>
+ </body>
+</html>
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41338,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get thread status
+ */
+
+ String threadStatus = (String) session
+ .getAttribute(SessionKeys.THREAD_STATUS);
+ if (threadStatus == null) {
+ MessageView error = new MessageView(41339,
+ LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) {
+ //
+ } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) {
+ response.sendRedirect(RedirectPages.REPLICATION_INFO);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) {
+ response.sendRedirect(RedirectPages.REPLICATION_NG);
+ return;
+ } else {
+ MessageView error = new MessageView(41340,
+ LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get Replication Info
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData repInfo = framework.getClusterData();
+ if (repInfo == null) {
+ MessageView error = new MessageView(41341,
+ LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ String repMaster = repInfo.self_ip;
+ String repSlave = repInfo.other_ip;
+
+ if ((repMaster == null) || (repSlave == null)) {
+ MessageView error = new MessageView(41342,
+ LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <meta http-equiv="refresh" content="<%= RedirectPages.REFRESH_TIME %>" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+
+ <link rel="stylesheet" type="text/css" href="l7gui_basic_style.css" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Replicating</title>
+</head>
+
+<body>
+<h1 class="title">Replicating</h1>
+<h2>Please wait.</h2>
+<h3>(Master) <%=repMaster%></h3>
+
+<img class="arrow1" src="images/arrowlogo1.gif" alt="arrowlogo1" />
+
+<h3>(Slave) <%=repSlave%></h3>
+
+</body>
+</html>
+
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41343,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get command message
+ */
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.COMMAND_MESSAGE);
+
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41344,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Failed To Replicate</title>
+</head>
+
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false" />
+
+<div id="content">
+<h1 class="title">Failed : Replication</h1>
+
+<h2>Error Reason :</h2>
+<%
+ if (errorMessage != null) {
+ out.println("<p class=\"error\"> [" + category + " - " + errorNumber + "] </p>");
+ out.println("<p class=\"error\">" + errorMessage + "</p>");
+ }
+%>
+</div>
+</body>
+</html>
+
+
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41345,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get thread status
+ */
+ String threadStatus = (String) session
+ .getAttribute(SessionKeys.THREAD_STATUS);
+ if (threadStatus == null) {
+ MessageView error = new MessageView(41346,
+ LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) {
+ //
+ } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) {
+ response.sendRedirect(RedirectPages.REPLICATION_INFO);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) {
+ response.sendRedirect(RedirectPages.REPLICATION_MODE_NG);
+ return;
+ } else {
+ MessageView error = new MessageView(41347,
+ LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get Replication Status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ReplicationData rep = framework.getReplicationData();
+ if (rep == null) {
+ MessageView error = new MessageView(41348,
+ LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ ReplicationStatus repStatus = rep.replicationMode;
+ String repChangeStatus = "";
+ String repNowStatus = "";
+
+ switch (repStatus) {
+ case MASTER:
+ repNowStatus = "Master Run";
+ repChangeStatus = "Master Stop";
+ break;
+ case MASTER_STOP:
+ repNowStatus = "Master Stop";
+ repChangeStatus = "Master Run";
+ break;
+ case SLAVE:
+ repNowStatus = "Slave Run";
+ repChangeStatus = "Slave Stop";
+ break;
+ case SLAVE_STOP:
+ repNowStatus = "Slave Stop";
+ repChangeStatus = "Slave Run";
+ break;
+ default:
+ MessageView error = new MessageView(41349,
+ LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <meta http-equiv="refresh" content="<%= RedirectPages.REFRESH_TIME %>" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+
+ <link rel="stylesheet" type="text/css" href="l7gui_basic_style.css" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Changing : Replication Mode</title>
+</head>
+<body>
+<h1 class="title">Changing : Replication Mode</h1>
+<h2>Please wait.</h2>
+<h3><%=repNowStatus%></h3>
+
+<img class="arrow1" src="images/arrowlogo1.gif" alt="arrowlogo1" />
+
+<h3><%=repChangeStatus%></h3>
+</body>
+</html>
+
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41350,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get command message
+ */
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.COMMAND_MESSAGE);
+
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41351,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Failed : Change Replication Mode</title>
+</head>
+
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false" />
+
+
+
+<div id="content">
+<h1>Failed : Change Replication Mode</h1>
+
+<h2>Error Reason :</h2>
+<%
+ if (errorMessage != null) {
+ out.println("<p class=\"error\"> [" + category + " - " + errorNumber + "] </p>");
+ out.println("<p class=\"error\">" + errorMessage + "</p>");
+ }
+%>
+</div>
+</body>
+</html>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*, org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*,java.util.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%
+ /*
+ * check session
+ */
+ if (session.isNew()) {
+ MessageView error = new MessageView(41352,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = null;
+ int errorNumber = 0;
+ String category = null;
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+
+ // get ValidationError Message
+ String invalidMessage = null;
+ invalidMessage = (String) session
+ .getAttribute(SessionKeys.INVALID_MESSAGE);
+ session.setAttribute(SessionKeys.INVALID_MESSAGE, null);
+
+ // get replicationData
+ L7guiFramework framework = new L7guiFramework();
+ ReplicationData rep = (ReplicationData)session.getAttribute(SessionKeys.INPUT_REP);
+
+ if (null == rep){
+ rep = framework.getReplicationData();
+ }
+
+ if (null == rep) {
+ MessageView error = new MessageView(41353,
+ LogCategorySet.GUI_IO, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get cluster status
+ */
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41354, LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico"/>
+
+ <title>Modify Replication Status</title>
+
+ </head>
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+
+ <div id="content">
+
+
+ <h1>Modify Replication Status</h1>
+
+ <%
+ if ( (message != null) && (errorMessage != null) ) {
+ %>
+ <p class="error">[<%=category%> - <%=errorNumber%>]</p>
+ <p class="error"><%=errorMessage%></p>
+ <%
+ }
+ %>
+
+ <form method="post" action="ReplicationInfoChangeServlet" name="rep_mod" >
+
+ <fieldset>
+ <legend>Replication Current Status</legend>
+ <table class="status">
+ <tr>
+ <th>
+ <label for="rep_interval">Interval</label>
+ </th>
+ <td>
+ <%
+ if ( ( null != invalidMessage ) && ( 0 == rep.interval ) ){
+ %>
+ <input type="text" id="rep_interval" value="" name="rep_interval" size="3" />
+ [µsec]
+ <%
+ }
+ else{
+ %>
+ <input type="text" id="rep_interval" value="<%= rep.interval %>" size="3" name="rep_interval" />
+ [µsec]
+ <%
+ }
+ if (null != invalidMessage) {
+ %>
+ <p class="invalid"> <%=invalidMessage%></p>
+ <%
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">10-10000(usec)</p>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+
+ <br />
+
+ <input type="submit" name="button" value="<%=ButtonMode.SAVE %>" onClick="return confirm(replication_modify_save)" />
+ <%
+ if (cd.self_status == ClusterStatus.ACTIVE
+ || cd.self_status == ClusterStatus.STANDBY) {
+ %>
+ <input type="submit" name="button" value="<%=ButtonMode.SAVESYNC %>" onClick="return confirm(replication_modify_savesync)" />
+ <%
+ }
+ %>
+ </form>
+ </div>
+ </body>
+</html>
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ session.invalidate();
+ MessageView error = new MessageView(41355,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get thread status
+ */
+ String threadStatus = (String) session
+ .getAttribute(SessionKeys.THREAD_STATUS);
+ if (threadStatus == null) {
+ MessageView error = new MessageView(41356,
+ LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) {
+ //
+ } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) {
+ response.sendRedirect(RedirectPages.REPLICATION_INFO);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) {
+ response.sendRedirect(RedirectPages.REPLICATION_MODIFY_NG);
+ return;
+ } else {
+ MessageView error = new MessageView(41357,
+ LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get Replication Status
+ */
+ String repNowInterval = (String) session
+ .getAttribute(SessionKeys.BEFORE_REP_TIME);
+ String repNewInterval = (String) session
+ .getAttribute(SessionKeys.AFTER_REP_TIME);
+
+ if ((repNowInterval == null) || (repNewInterval == null)) {
+ MessageView error = new MessageView(41358,
+ LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <meta http-equiv="refresh" content="<%= RedirectPages.REFRESH_TIME %>" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+
+ <link rel="stylesheet" type="text/css" href="l7gui_basic_style.css" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Modifying : Replication Interval</title>
+</head>
+
+<body>
+<h1 class="title">Modifying : Replication Interval</h1>
+<h2>Please wait.</h2>
+<h3><%=repNowInterval%> [µsec]</h3>
+
+<img class="arrow1" src="images/arrowlogo1.gif" alt="arrowlogo1" />
+
+<h3><%=repNewInterval%>[µsec]</h3>
+</body>
+</html>
+
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41359,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get command message
+ */
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.COMMAND_MESSAGE);
+
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41360,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Failed : Modify Replication Interval</title>
+</head>
+
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false" />
+
+<div id="content">
+<h1 class="title">Failed : Modify Replication Interval</h1>
+<h2>Error Reason :</h2>
+<%
+ if (errorMessage != null) {
+ out.println("<p class=\"error\"> [" + category + " - " + errorNumber + "] </p>");
+ out.println("<p class=\"error\">" + errorMessage + "</p>");
+ }
+%>
+</div>
+</body>
+</html>
+
+
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*, java.util.*,
+ java.io.File, java.util.Calendar, java.util.Date, java.text.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%
+
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41361, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+ /*
+ * get command message
+ */
+ MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE);
+ String commandMessage = "";
+ int commandNumber = 0;
+ String commandCategory = "";
+ if (commandmessage != null) {
+ commandMessage = commandmessage.getMessage();
+ commandNumber = commandmessage.getErrno();
+ commandCategory = commandmessage.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ /*
+ * get save status
+ */
+ String saveLogStatus = (String)session.getAttribute(SessionKeys.LOG_SAVE_STATE);
+ String saveVsStatus = (String)session.getAttribute(SessionKeys.VS_SAVE_STATE);
+
+ if ((saveLogStatus == null) || (saveVsStatus == null)){
+ MessageView error = new MessageView(41362, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ if (saveLogStatus.equals(SessionKeys.SAVE)){
+ saveLogStatus = "Save";
+ }
+ else if (saveLogStatus.equals(SessionKeys.NO_SAVE)){
+ saveLogStatus = "No Save";
+ }
+
+ if(saveVsStatus.equals(SessionKeys.SAVE)){
+ saveVsStatus = "Save";
+ }
+ else if (saveVsStatus.equals(SessionKeys.NO_SAVE)){
+ saveVsStatus = "No Save";
+ }
+
+ /*
+ * get save file info
+ */
+ final String logConfName = "/etc/l7vs/l7vs.cf";
+
+ final String vsConfName = "/etc/ha.d/conf/l7directord.cf";
+
+ File logConfFile = new File(logConfName);
+ File vsConfFile = new File(vsConfName);
+ String logDisplayTime = null;
+ String vsDisplayTime = null;
+ long logConfTime = logConfFile.lastModified();
+ long vsConfTime = vsConfFile.lastModified();
+
+ if (logConfTime == 0){
+ logDisplayTime = "-";
+ }
+ else{
+ // get logConfTime
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.JAPAN);
+ logDisplayTime = sdf.format(new Long(logConfTime));
+}
+
+ if (vsConfTime == 0){
+ vsDisplayTime = "-";
+ }
+ else{
+ // get vsConfTime
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.JAPAN);
+ vsDisplayTime = sdf.format(new Long(vsConfTime));
+ }
+
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41363, LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+
+ <title>Save Resources</title>
+ </head>
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+
+ <div id="content">
+
+ <h1>Save Resources</h1>
+
+ <%
+ if (message != null) {
+ %>
+
+ <p class="error">[<%=category %>-<%=errorNumber %>]</p>
+ <p class="error"><%=errorMessage %></p>
+
+ <%
+ }
+ else if ((commandmessage != null) && (commandMessage != null) ){
+ %>
+ <p class="success">[<%=commandCategory %>-<%=commandNumber %>]</p>
+ <p class="success"><%=commandMessage %></p>
+ <%
+ }
+ %>
+
+
+ <form method="post" action="SaveStateServlet">
+ <fieldset class="">
+ <legend>Save / No Save Info</legend>
+
+ <table class="infotable" cellspacing="0">
+ <thead>
+ <tr>
+ <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>
+ </thead>
+ <tbody>
+ <tr>
+ <td class="center"><input type="checkbox" name="save_category" value="save_log" /></td>
+ <td><%= saveLogStatus %></td>
+ <td>Log</td>
+ <td> Log setting<br />(except GUI & Sync)</td>
+ <td><%=logConfName %></td>
+ <td><%=logDisplayTime %></td>
+ </tr>
+ <tr>
+ <td class="center"><input type="checkbox" name="save_category" value="save_service" /></td>
+ <td><%= saveVsStatus %></td>
+ <td>Service</td>
+ <td>VirtualService settings</td>
+ <td><%=vsConfName %></td>
+ <td><%=vsDisplayTime %></td>
+ </tr>
+ </tbody>
+ </table>
+ </fieldset>
+
+
+ <input type="submit" name="button" value="<%=ButtonMode.SAVE%>" onClick="return confirm(save)" />
+ </form>
+
+ </div>
+ </body>
+</html>
\ No newline at end of file
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41364,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.RESULT_MESSAGE);
+
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41365,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Failed : Save Resources</title>
+</head>
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false" />
+
+<div id="content">
+
+<h1 class="title">Failed : Save Resources</h1>
+<% if ( (message != null) && (errorMessage != null) ){
+%>
+ <h2>Error Reason :</h2>
+ <p class="error">[<%=category%>-<%=errorNumber%>]</p>
+ <p class=error><%=errorMessage%></p>
+<%}
+%>
+</div>
+</body>
+</html>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41366, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get sessionTrans
+ */
+ SessionTransData sessionTrans = (SessionTransData) session.getAttribute(SessionKeys.PAGE_TRANSDATA);
+ if (sessionTrans == null){
+ MessageView error = new MessageView(41367, LogCategorySet.GUI_SAVE_SYNC, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ String successpage = sessionTrans.destURI;
+ String failpage = sessionTrans.errorURI;
+
+ /*
+ * get thread status
+ */
+ String threadStatus = (String) session.getAttribute(SessionKeys.THREAD_STATUS);
+ if (threadStatus == null) {
+ MessageView error = new MessageView(41368, LogCategorySet.GUI_SAVE_SYNC, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ if((successpage == null) || (failpage == null)){
+ MessageView error = new MessageView(41369, LogCategorySet.GUI_SAVE_SYNC, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ else {
+ if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)){
+ response.sendRedirect(successpage);
+ return;
+ }
+ else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)){
+ // nothing to do
+ }
+ else if (threadStatus.equals(SessionKeys.THREAD_FAIL)){
+ response.sendRedirect(failpage);
+ return;
+ }
+ else {
+ MessageView error = new MessageView(41370, LogCategorySet.GUI_SAVE_SYNC, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ }
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.REFRESH_TIME %>"/>
+
+ <link rel="stylesheet" type="text/css" href="l7gui_basic_style.css" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Running : Save and Sync</title>
+</head>
+
+<body>
+
+<h1 class="title">Running : Save and Sync</h1>
+<h2>Please wait.</h2>
+
+</body>
+</html>
+
--- /dev/null
+
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41371, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+ /*
+ * get command message
+ */
+ MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE);
+ String commandMessage = "";
+ int commandNumber = 0;
+ String commandCategory = "";
+ if (commandmessage != null) {
+ commandMessage = commandmessage.getMessage();
+ commandNumber = commandmessage.getErrno();
+ commandCategory = commandmessage.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ /*
+ * get validation error message
+ */
+ String invalidMessage = "";
+ invalidMessage = (String)session.getAttribute(SessionKeys.INVALID_MESSAGE);
+ session.setAttribute(SessionKeys.INVALID_MESSAGE, null);
+
+ /*
+ * get SnmpAgentData
+ */
+ SnmpAgentData input_snmp = (SnmpAgentData)session.getAttribute(SessionKeys.INPUT_SNMP);
+ String unit_snmpInterval = (String)session.getAttribute(SessionKeys.INPUT_SNMP_UNIT);
+ SnmpAgentData snmp = new SnmpAgentData();
+ L7guiFramework framework = new L7guiFramework();
+
+ //from session
+ if(input_snmp != null){
+ snmp = input_snmp ;
+ }
+ //from Framework
+ else{
+ snmp = framework.getSnmpAgentData();
+ if ( snmp == null ){
+ MessageView error = new MessageView(41372, LogCategorySet.GUI_SNMP, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ if((snmp.interval >= 1) && (snmp.interval <= 999)){
+ unit_snmpInterval = "ms";
+ }
+ else if(snmp.interval >= 1000){
+ unit_snmpInterval = "s";
+ snmp.interval /= 1000;
+ }
+ else{
+ unit_snmpInterval = "ms";
+ }
+ }
+ session.setAttribute(SessionKeys.INPUT_SNMP, null);
+ session.setAttribute(SessionKeys.INPUT_SNMP_UNIT, null);
+
+ /*
+ * get cluster status
+ */
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41373, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+%>
+
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>SNMP Agent</title>
+ </head>
+
+ <body class="normal">
+
+ <jsp:include page="menu.jsp" flush="false"/>
+
+ <div id ="content">
+ <h1 class="title">SNMP Agent</h1>
+
+ <%
+ if (message != null) {
+ %>
+ <p class="error">[<%=category %>-<%=errorNumber %>]</p>
+ <p class="error"><%=errorMessage %></p>
+ <%
+ }
+ %>
+ <%
+ if (commandmessage != null) {
+ %>
+ <p class="success">[<%=commandCategory %>-<%=commandNumber %>]</p>
+ <p class="success"><%=commandMessage %></p>
+ <%
+ }
+ %>
+
+ <form method="post" action="SnmpAgentServlet" name="snmp" >
+
+ <fieldset>
+ <legend>SNMP Agent Current Status</legend>
+ <table class="status">
+ <tr>
+ <th>
+ <label for="snmp_interval">Query Interval</label>
+ </th>
+ <td>
+ <%
+ if((null != invalidMessage) && (snmp.interval == 1)){
+ out.print("<input type=\"text\" maxlength=\"3\" id=\"snmp_interval\" value=\"\" name=\"snmp_interval\" size=\"3\" />");
+ }
+ else if(invalidMessage != null){
+ out.print("<input type=\"text\" maxlength=\"3\" id=\"snmp_interval\" value=\"" + snmp.interval + "\"name=\"snmp_interval\" size=\"3\" />");
+ }
+ else{
+ out.print("<input type=\"text\" maxlength=\"3\" id=\"snmp_interval\" value=\"" + snmp.interval + "\"name=\"snmp_interval\" size=\"3\" />");
+ }
+ %>
+
+ <select id="snmp_interval" name="unit_interval">
+ <option value="ms" <%if (unit_snmpInterval.equals("ms"))
+ out.print("selected");%>>msec</option>
+ <option value="s"<%if (unit_snmpInterval.equals("s"))
+ out.print("selected");%>>sec</option>
+ </select>
+ <%
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">1-999(msec/sec)</p>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+
+ <input type="submit" name="button" value="<%=ButtonMode.SAVE %>" onClick="return confirm(snmp_save)" />
+ <%
+ if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) {
+ %>
+ <input type="submit" name="button" value="<%=ButtonMode.SAVESYNC %>" onClick="return confirm(snmp_savesync)" />
+ <%
+ }
+ %>
+
+ </form>
+ <%-- // Delete when SNMP Agent finish.--%>
+ <% if (snmp.status == SnmpAgentStatus.CONNECTING) { %>
+ <h2> MIB Download</h2>
+ <h4>Please push the following button,if you would like to download the SNMP MIB related to the UltraMonkey-L7.</h4>
+ <form action="MIB.zip">
+ <input type="submit" value="Download" />
+ </form>
+ <%
+ }
+ %>
+
+</div>
+</body>
+</html>
+
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ // session.invalidate();
+ MessageView error = new MessageView(41374,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get thread status
+ */
+
+ String threadStatus = (String) session
+ .getAttribute(SessionKeys.THREAD_STATUS);
+
+ if (threadStatus == null) {
+ MessageView error = new MessageView(41375, LogCategorySet.GUI_SNMP,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) {
+ //
+ } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) {
+ response.sendRedirect(RedirectPages.SNMP_MODIFY);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) {
+ response.sendRedirect(RedirectPages.SNMP_MODIFY_NG);
+ return;
+ } else {
+ MessageView error = new MessageView(41376, LogCategorySet.GUI_SNMP,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <meta http-equiv="refresh" content="<%= RedirectPages.REFRESH_TIME %>" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="l7gui_basic_style.css" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Modifying : SNMP Agent</title>
+</head>
+
+<body>
+<h1 class="title">Modifying : SNMP Agent</h1>
+<h2>Please wait.</h2>
+</body>
+
+</html>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*, org.ultramonkey.l7.controller.*, org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+
+
+<%
+ /*
+ * check session
+ */
+ if (session.isNew()) {
+ MessageView error = new MessageView(41377, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+
+ /*
+ * get command message
+ */
+ MessageView message = (MessageView)session.getAttribute(SessionKeys.COMMAND_MESSAGE);
+
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41378, LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Failed : Modify SNMP Agent</title>
+</head>
+
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false"/>
+
+
+
+<div id="content">
+<h1 class="title">Failed : Modify SNMP Agent</h1>
+
+ <h2> Error Reason : </h2>
+<%
+ if (errorMessage != null) {
+ out.println("<p class=\"error\"> [" + category + " - " + errorNumber + "] </p>");
+ out.println("<p class=\"error\">" + errorMessage + "</p>");
+ }
+%>
+
+</div>
+</body>
+</html>
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41379,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get thread status
+ */
+ String threadStatus = (String) session
+ .getAttribute(SessionKeys.THREAD_STATUS);
+ if (threadStatus == null) {
+ MessageView error = new MessageView(41380,
+ LogCategorySet.GUI_REDUNDANT, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) {
+ // nothing to do
+ } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) {
+ response.sendRedirect(RedirectPages.SO_OK);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) {
+ response.sendRedirect(RedirectPages.SO_NG);
+ return;
+ } else {
+ MessageView error = new MessageView(41381,
+ LogCategorySet.GUI_REDUNDANT, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.REFRESH_TIME %>" />
+
+ <link rel="stylesheet" type="text/css" href="l7gui_basic_style.css" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Running : Switch-Over</title>
+</head>
+
+<body>
+
+<h1 class="title">Running : Switch-Over</h1>
+<h2>Please wait.</h2>
+
+</body>
+</html>
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41382,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.COMMAND_MESSAGE);
+
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41383,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Failed : Switch-Over</title>
+</head>
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false" />
+
+<div id="content">
+<h1 class="title">Failed : Switch-Over</h1>
+<h2>Please try again.</h2>
+<% if ( (message != null) && (errorMessage != null) ) {
+%>
+<h2>Error Reason :</h2>
+<p class="error">[<%=category%>-<%=errorNumber%>]</p>
+<p class=error><%=errorMessage%></p>
+<%
+}
+%>
+</div>
+</body>
+</html>
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41384,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get VS IPaddress
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+
+ String self = "";
+ String other = "";
+
+ if (cd == null) {
+ MessageView error = new MessageView(41385,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute("resultMessage", error);
+ response.sendRedirect("index.jsp");
+ return;
+ } else {
+ self = cd.self_ip;
+ other = cd.other_ip;
+ }
+ if ((self == null) || (other == null)) {
+ MessageView error = new MessageView(41386,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Succeeded : Switch-Over</title>
+</head>
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false" />
+
+<div id="content">
+<h1 class="title">Succeeded : Switch-Over</h1>
+<fieldset class="">
+<legend>Current Status</legend>
+<table class="infotable">
+<tr>
+ <th class="center">
+ <label for="empty"></label>
+ </th>
+ <th class="center">
+ Self Node
+ </th>
+ <th class="center">
+ Peer Node
+ </th>
+</tr>
+<tr>
+ <th class="left">
+ <label for="nodeStatus">Node Status</label>
+ </th>
+ <td>
+ <%= cd.self_status %>
+ </td>
+ <td>
+ <%= cd.other_status %>
+ </td>
+</tr>
+<tr>
+ <th class="left">
+ <label for="realIp">Real IP Address</label>
+ </th>
+ <td>
+ <%= cd.self_ip %>
+ </td>
+ <td>
+ <%= cd.other_ip %>
+ </td>
+</tr>
+</table>
+</fieldset>
+</div>
+</body>
+</html>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*, java.util.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
+%>
+<%
+
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41387, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+ /*
+ * get command message
+ */
+ MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE);
+ String commandMessage = "";
+ int commandNumber = 0;
+ String commandCategory = "";
+ if (commandmessage != null) {
+ commandMessage = commandmessage.getMessage();
+ commandNumber = commandmessage.getErrno();
+ commandCategory = commandmessage.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41388, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ session.setAttribute("cd",cd);
+
+ /*
+ * get sync status and get self/other IP
+ */
+ String syncLogStatus = null;
+ String syncMonitorStatus = null;
+ String syncServiceStatus = null;
+ String syncRepStatus = null;
+ String syncSnmpStatus = null;
+ String syncGuiStatus = null;
+ String selfIp = null;
+ String otherIp = null;
+
+
+ if ( (cd.self_status == ClusterStatus.ACTIVE ) || (cd.self_status == ClusterStatus.STANDBY) ){
+ // get sync Status
+ syncLogStatus = (String)session.getAttribute(SessionKeys.LOG_SYNC_STATE);
+ syncMonitorStatus = (String)session.getAttribute(SessionKeys.MONITOR_SYNC_STATE);
+ syncServiceStatus = (String)session.getAttribute(SessionKeys.VS_SYNC_STATE);
+ syncRepStatus = (String)session.getAttribute(SessionKeys.REP_SYNC_STATE);
+ syncSnmpStatus = (String)session.getAttribute(SessionKeys.SNMP_SYNC_STATE);
+ syncGuiStatus = (String)session.getAttribute(SessionKeys.GUI_SYNC_STATE);
+ if ( (syncLogStatus == null) || (syncMonitorStatus == null) || (syncServiceStatus == null)
+ || (syncRepStatus == null) || (syncSnmpStatus == null) || (syncGuiStatus == null) ){
+
+ MessageView error = new MessageView(41389, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ // get Self/Other IP
+ selfIp = cd.self_ip;
+ otherIp = cd.other_ip;
+ if ( (selfIp == null) || (otherIp == null) ){
+ MessageView error = new MessageView(41390, LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ }
+
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+
+%>
+
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+ <html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+
+ <title>Sync Resources</title>
+ </head>
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+
+ <div id="content">
+
+ <h1>Sync Resources</h1>
+ <% if ( (cd.self_status != ClusterStatus.ACTIVE ) && (cd.self_status != ClusterStatus.STANDBY) ){
+ %>
+ <p class="error">"Sync Resources" function is effective only when cluster is applied. </p>
+ <%
+ }
+ else {
+
+ if (message != null) {
+ %>
+
+ <p class="error">[<%=category %>-<%=errorNumber %>]</p>
+ <p class="error"><%=errorMessage %></p>
+
+ <%
+ }
+ else if (commandmessage != null ){
+ %>
+ <p class="success">[<%=commandCategory %>-<%=commandNumber %>]</p>
+ <p class="success"><%=commandMessage %></p>
+ <%
+ }
+ %>
+
+
+ <form method="post" action="SyncStateServlet" name="sync">
+ <fieldset class="">
+ <legend>Sync Info</legend>
+ <h3> <%= selfIp %> <img class="arrow2" src="images/arrowlogo2.gif" alt="arrowlogo" /> <%=otherIp %> </h3>
+
+
+ <table class="infotable" cellspacing="0">
+ <thead>
+ <tr>
+ <th>Sync<br />CHECK</th><th>Category</th><th>Description</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td class="center"><input type="checkbox" name="sync_category" value="log_all"></td>
+ <td class="left">Log</td>
+ <td class="left"> Log settings</td>
+ </tr>
+ <tr>
+ <td class="center"><input type="checkbox" name="sync_category" value="monitor"></td>
+ <td class="left">Monitor</td>
+ <td class="left">Monitor settings</td>
+ </tr>
+ <tr>
+ <td class="center"><input type="checkbox" name="sync_category" value="service"></td>
+ <td class="left">Service</td>
+ <td class="left">VirtualService settings</td>
+ </tr>
+ <tr>
+ <td class="center"><input type="checkbox" name="sync_category" value="replication_info"></td>
+ <td class="left">Replication</td>
+ <td class="left">Replication settings</td>
+ </tr>
+ <tr>
+ <td class="center"><input type="checkbox" name="sync_category" value="snmp_info"></td>
+ <td class="left">SNMP Agent</td>
+ <td class="left">SNMP Agent settings</td>
+ </tr>
+ <tr>
+ <td class="center"><input type="checkbox" name="sync_category" value="userdata"></td>
+ <td class="left">GUI</td>
+ <td class="left">GUI User Management (Users & Password)</td>
+ </tr>
+ </tbody>
+ </table>
+ </fieldset>
+
+ <input type="submit" name="button" value="<%=ButtonMode.SAVESYNC%>" onClick="return confirm(savesync)" />
+
+</form>
+ <%
+ }
+ %>
+ </div>
+ </body>
+</html>
\ No newline at end of file
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41391,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get sync info (VS IPaddress)
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+
+ String self = "";
+ String other = "";
+
+ if (cd == null) {
+ MessageView error = new MessageView(41392,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ } else {
+ self = cd.self_ip;
+ other = cd.other_ip;
+ }
+
+ /*
+ * get thread status
+ */
+ String threadStatus = (String) session
+ .getAttribute(SessionKeys.THREAD_STATUS);
+ if (threadStatus == null) {
+ MessageView error = new MessageView(41393, LogCategorySet.GUI_SYNC,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ } else if (threadStatus == SessionKeys.THREAD_RUNNING) {
+ // nothing to do
+ } else if (threadStatus == SessionKeys.THREAD_SUCCESS) {
+ response.sendRedirect(RedirectPages.SYNC);
+ return;
+ } else if (threadStatus == SessionKeys.THREAD_FAIL) {
+ response.sendRedirect(RedirectPages.SYNC_NG);
+ return;
+ } else {
+ MessageView error = new MessageView(41394, LogCategorySet.GUI_SYNC,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.REFRESH_TIME %>" />
+
+ <link rel="stylesheet" type="text/css" href="l7gui_basic_style.css" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Running : Sync Resources</title>
+</head>
+
+<body>
+
+<h1 class="title">Running : Sync Resources</h1>
+<h2>Please wait.</h2>
+
+
+<%
+ if ((self != null) && (other != null)){
+%>
+ <h2><%=self %> (<%=cd.self_status %>) <img class="arrow2" src="images/arrowlogo2.gif"
+ alt="arrowlogo" /><%=other %> (<%=cd.other_status %>)</h2>
+
+<%
+ }
+%>
+
+
+</body>
+</html>
+
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41395,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get VS IPaddress
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+
+ String self = "";
+ String other = "";
+
+ if (cd == null) {
+ MessageView error = new MessageView(41396,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ } else {
+ self = cd.self_ip;
+ other = cd.other_ip;
+ }
+
+ if ((self == null) || (other == null)) {
+ MessageView error = new MessageView(41397,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.COMMAND_MESSAGE);
+
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<meta http-equiv="Content-Script-Type" content="text/javascript" />
+<meta http-equiv="Content-Style-Type" content="text/css" />
+<noscript>
+<meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+</noscript>
+<link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+<link rel="shortcut icon" href="images/favicon.ico" />
+<title>Failed : Sync Resources</title>
+</head>
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false" />
+
+<div id="content">
+<h1 class="title">Failed : Sync Resources</h1>
+<h2>Sync failed.</h2>
+
+<h2><%=self%> (<%=cd.self_status %>) <img class="arrow2" src="images/arrowlogo2.gif"
+ alt="arrowlogo" /><%=other %> (<%=cd.other_status %>)</h2>
+
+<% if ( (message != null ) && (errorMessage != null)){
+%>
+<h2>Error Reason :</h2>
+<p class="error">[<%=category%>-<%=errorNumber%>]</p>
+<p class=error><%=errorMessage%></p>
+<%
+}
+%>
+</div>
+</body>
+</html>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*, org.ultramonkey.l7.controller.*, org.ultramonkey.l7.view.*, java.util.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%
+
+ /*
+ * check session
+ */
+ if (session.isNew()) {
+ MessageView error = new MessageView(41398, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = null;
+ int errorNumber = 0;
+ String category = "";
+ if ( (message != null) && (errorMessage != null) ) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+ /*
+ * get l7vsadm data from L7guiFramework
+ */
+ L7guiFramework framework = new L7guiFramework();
+ L7vsAdmData admDataList = framework.getAdmData();
+ if (admDataList == null) {
+ MessageView error = new MessageView(41399, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get directord data from L7guiFramework
+ */
+ DirectorData dd = framework.getDirectorData();
+ if (dd == null){
+ MessageView error = new MessageView(41400, LogCategorySet.GUI_IO_FILE,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ String checkTimeout = dd.checkTimeOut;
+ if ( (checkTimeout == null) || (checkTimeout.length() == 0) )
+ checkTimeout = "-";
+ else
+ checkTimeout = checkTimeout + " [sec]";
+
+ String negotiateTimeOut = dd.negotiateTimeOut;
+ if ( (negotiateTimeOut == null) || (negotiateTimeOut.length() == 0) )
+ negotiateTimeOut = "-";
+ else
+ negotiateTimeOut = negotiateTimeOut + " [sec]";
+
+ String checkInterval = dd.checkInterval;
+ if ( (checkInterval == null) || (checkInterval.length() == 0) )
+ checkInterval = "-";
+ else
+ checkInterval = checkInterval + " [sec]";
+
+ String checkCount = dd.checkCount;
+ if ( (checkCount == null) || (checkCount.length() == 0) )
+ checkCount = "-";
+ else
+ checkCount = checkCount + " [times]";
+
+ String callback = dd.callback;
+ if ( (callback == null) || (callback.length() == 0) )
+ callback = "-";
+
+ String fallback = dd.fallback;
+ if ( (fallback == null) || (fallback.length() == 0) )
+ fallback = "-";
+
+ String logFile = dd.logfile;
+ if ( (logFile == null) || (logFile.length() == 0) )
+ logFile = "-";
+ String execute = dd.execute;
+ if ( (execute == null) || (execute.length() == 0) )
+ execute = "-";
+
+ String supervised = dd.supervised;
+ if ( (supervised == null) || (supervised.length() == 0) )
+ supervised = "-";
+
+ String quiescent = dd.quiescent;
+ if ( (quiescent == null) || (quiescent.length() == 0) )
+ quiescent = "-";
+
+
+ /*
+ * get cluster status and fix css seat
+ */
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41401, LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ // IP CHECK
+ String selfIp = cd.self_ip;
+ String otherIp = cd.other_ip;
+
+ if ( selfIp == null )
+ selfIp = "";
+ if (otherIp == null )
+ otherIp = "";
+
+
+ /*
+ * get snmpAgent Data
+ */
+ SnmpAgentData snmp = framework.getSnmpAgentData();
+ if ( snmp == null ) {
+ MessageView error = new MessageView(41402, LogCategorySet.GUI_IO_COMMAND,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ int query = snmp.interval;
+ String queryUnit = "[msec]";
+ if (query > 1000){
+ query = query / 1000 ;
+ queryUnit = "[sec]";
+ }
+
+ /*
+ * get replication Data
+ */
+ ReplicationData rep = framework.getReplicationData();
+ if ( rep == null ) {
+ MessageView error = new MessageView(41403, LogCategorySet.GUI_IO_COMMAND,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ ReplicationStatus repStatus = rep.replicationMode;
+ String printRepStatus = null;
+ switch (repStatus){
+ case MASTER:
+ printRepStatus = "Master Running";
+ break;
+ case SLAVE:
+ printRepStatus = "Slave Running";
+ break;
+ case MASTER_STOP:
+ printRepStatus = "Master Stopped";
+ break;
+ case SLAVE_STOP:
+ printRepStatus = "Slave Stopped";
+ break;
+ case SINGLE:
+ printRepStatus = "Replication Invalid";
+ break;
+ case OUT:
+ printRepStatus = "In Starting Replication";
+ break;
+ default :
+ MessageView error = new MessageView(41404, LogCategorySet.GUI_IO_COMMAND,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+
+
+ /*
+ * get process status
+ */
+ String l7vsdStatus = "Out of Service";
+ String l7vsdClass = "error";
+ String l7direcotordStatus = "Out of Service";
+ String l7directordClass = "error";
+ String snmpAgentStatus = "Out of Service";
+ String snmpAgentClass = "error" ;
+ String replicationStatus = "Out of Service";
+ String replicationClass = "side_error";
+ String clusterStatus = null;
+ String clusterClass = "error";
+
+ // fix l7vsd Status
+ if ( framework.getL7vsdProcessStatus() ){
+ l7vsdStatus = "In Service";
+ l7vsdClass = "ins";
+ }
+
+ // fix l7direcotord Status
+ if ( framework.getL7directordProcessStatus() ){
+ l7direcotordStatus = "In Service";
+ l7directordClass = "ins";
+ }
+
+ // fix snmpAgent Status
+ if ( snmp.status == SnmpAgentStatus.CONNECTING ){
+ snmpAgentStatus = "In Service";
+ snmpAgentClass = "ins";
+ }
+
+ // fix replication Status
+ if ( rep.replicationMode != ReplicationStatus.SINGLE && rep.replicationMode != ReplicationStatus.OUT ){
+ replicationStatus = "In Service";
+ replicationClass = "side_ins";
+ }
+
+ // fix Cluster Status
+ if ( (cd.self_status.equals(ClusterStatus.ACTIVE)) || (cd.self_status.equals(ClusterStatus.STANDBY)) ){
+ clusterStatus = "In Service";
+ if (cd.self_status.equals(ClusterStatus.ACTIVE) )
+ clusterClass = "ins";
+ }
+
+
+ /*
+ * fix css seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>GUI Console TOP</title>
+ </head>
+
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+
+
+ <div id="content">
+
+ <h1>GUI Console TOP</h1>
+ <h2> UltraMonkey-L7 Service</h2>
+
+ <fieldset class="">
+ <legend>UltraMoneky-L7 Service : Current status</legend>
+
+ <table class="infotable">
+ <%
+ if (clusterStatus != null){
+ %>
+ <tr>
+ <th class="head" colspan="4">
+ <label for="UltraMoneky-L7">UltraMoneky-L7</label>
+ </th>
+ <th class="head">
+ <label for="HA Cluster">HA Cluster</label>
+ </th>
+ </tr>
+ <%
+ }
+ %>
+ <tr>
+ <th>
+ <label for="l7vsdStatus">l7vsd</label>
+ </th>
+ <th>
+ <label for="l7directord">l7directord</label>
+ </th>
+ <th>
+ <label for="SNMPAgent">SNMPAgent</label>
+ </th>
+ <th class="point">
+ <label for="Replication">Replication</label>
+ </th>
+ <%
+ if (clusterStatus != null){
+ %>
+ <th>
+ <label for="Heartbeat2">Heartbeat2</label>
+ </th>
+ <%
+ }
+ %>
+ </tr>
+ <tr>
+ <td class="<%=l7vsdClass %>"><%=l7vsdStatus %></td>
+ <td class="<%=l7directordClass %>"><%=l7direcotordStatus %></td>
+ <td class="<%=snmpAgentClass %>"><%=snmpAgentStatus %></td>
+ <td class="<%=replicationClass %>"><%=replicationStatus %></td>
+ <% if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY){
+ %>
+ <td class="<%=clusterClass %>"><%= clusterStatus %></td>
+ <%
+ }
+ %>
+ </tr>
+ </table>
+ </fieldset>
+
+
+ <h2>Redundancy</h2>
+ <fieldset class="">
+ <legend>Redundancy : Current Status</legend>
+
+ <table class="infotable">
+ <tr>
+ <th class="point">
+ <label for="empty"></label>
+ </th>
+ <th>
+ <label for="nodeStatus">Node Status</label>
+ </th>
+ <th>
+ <label for="realIp">Real IP Address</label>
+ </th>
+ </tr>
+ <tr>
+ <td class="left_point">
+ Self Node
+ </td>
+ <td class="center">
+ <%= cd.self_status %>
+ </td>
+ <td class="center">
+ <%= selfIp %>
+ </td>
+ </tr>
+ <% if (cd.self_status != ClusterStatus.SINGLE){
+ %>
+ <tr>
+ <td class="left_point">
+ Peer Node
+ </td>
+ <td class="center">
+ <%= cd.other_status %>
+ </td>
+ <td class="center">
+ <%= otherIp %>
+ </td>
+ </tr>
+ <% }
+ %>
+ </table>
+ </fieldset>
+
+
+ <h2> VirtualService</h2>
+ <% if ( (cd.self_status.equals(ClusterStatus.ACTIVE)) || (cd.self_status.equals(ClusterStatus.SINGLE) )){
+ %>
+ <%
+ /*
+ * get VirtualService data from L7guiFramework
+ */
+ Vector<VirtualSetting> vsList = new Vector<VirtualSetting>();
+ vsList = admDataList.virtualSettings;
+ ArrayList<String> vsNameList = new ArrayList<String>();
+ vsNameList.clear();
+
+ String vsIp = null;
+ String vsPort = null;
+ String vsProtomod = null;
+ String vsOption = null;
+ String vsSchedule = null;
+ String rsIP = null;
+ String rsPort = null;
+ int rsWeight = 0;
+ long activeConnections = 0;
+ long inactiveConnections = 0;
+ String vsSorryFlag = null;
+
+ if ( vsList.size() > 0 ){
+ %>
+ <fieldset class="">
+ <legend>VirtualService : Current Status</legend>
+ <table class="infotable" cellspacing="0">
+ <tr>
+ <th class="head" colspan="5">
+ <label for="VirtualService">VirtualService</label>
+ </th>
+ <th class="head" colspan="5">
+ <label for="RealServices">RealServer</label>
+ </th>
+ <th rowspan="2">
+ <label for="SorryFlag">Sorry Flag</label>
+ </th>
+ </tr>
+ <tr>
+ <th>
+ <label for="VirtualIP Address">VirtualIP Address</label>
+ </th>
+ <th>
+ <label for="Port Number">Port Number</label>
+ </th>
+ <th>
+ <label for="Persistence Type">Persistence Type</label>
+ </th>
+ <th>
+ <label for="Module option">Module Option</label>
+ </th>
+ <th class="point">
+ <label for="Scheduler Type">Scheduler Type</label>
+ </th>
+ <th>
+ <label for="RealServer IP Address">IP Address</label>
+ </th>
+ <th>
+ <label for="RealServer Port Number">Port Number</label>
+ </th>
+ <th>
+ <label for="RealServer weight">Weight</label>
+ </th>
+ <th>
+ <label for="ActiveConnections">Active Connections</label>
+ </th>
+ <th class="point">
+ <label for="InactiveConnections">Inactive Connections</label>
+ </th>
+ </tr>
+ <%
+ for (int i = 0; i < vsList.size(); i++) {
+ try {
+ VirtualSetting getVirtualSetting = vsList.get(i);
+
+ vsIp = getVirtualSetting.virtual.host;
+ vsPort = getVirtualSetting.virtual.port;
+ vsProtomod = getVirtualSetting.protomod;
+ vsOption = getVirtualSetting.option;
+ vsSchedule = getVirtualSetting.sched;
+
+ Vector<EndPoint> getRsList =getVirtualSetting.real;
+ int rsNumber = getRsList.size();
+ if ( rsNumber < 0 ){
+ rsNumber = 1;
+ }
+
+ boolean vsSorry = getVirtualSetting.sorryflag;
+
+ if ( (vsIp == null) || (vsProtomod == null) || (vsOption == null) ){
+ MessageView error = new MessageView(41405, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ %>
+ <tr>
+ <td class="center" rowspan="<%=rsNumber %>"><%=vsIp%></td>
+ <td class="center" rowspan="<%=rsNumber %>"><%=vsPort%></td>
+ <td class="center" rowspan="<%=rsNumber %>"><%=vsProtomod%></td>
+ <td class="center" rowspan="<%=rsNumber %>"><%=vsOption%></td>
+ <td class="point" rowspan="<%=rsNumber %>"><%=vsSchedule%></td>
+ <%
+ if ( rsNumber < 1 ){
+ %>
+ <td class="center">-</td>
+ <td class="center">-</td>
+ <td class="center">-</td>
+ <td class="center">-</td>
+ <td class="point">-</td>
+ <%
+ }
+ else{
+ EndPoint getRs = getRsList.get(0);
+ rsIP = getRs.host;
+ rsPort = getRs.port;
+ rsWeight = getRs.weight;
+ activeConnections = getRs.actConn;
+ inactiveConnections = getRs.inActConn;
+ %>
+ <td class="center"><%=rsIP%></td>
+ <td class="center"><%=rsPort%></td>
+ <td class="center"><%=rsWeight%></td>
+ <td class="center"><%=activeConnections%></td>
+ <td class="point"><%=inactiveConnections%></td>
+ <%
+ }
+ if(vsSorry == true){
+ vsSorryFlag = "On";
+ }
+ else {
+ vsSorryFlag = "Off";
+ }
+ %>
+ <td class="center" rowspan="<%=rsNumber %>"><%=vsSorryFlag %></td>
+ </tr>
+ <%
+ for ( int j = 1; j < rsNumber; j++ ){
+ EndPoint addedGetRs = getRsList.get(j);
+ rsIP = addedGetRs.host;
+ rsPort = addedGetRs.port;
+ rsWeight = addedGetRs.weight;
+ activeConnections = addedGetRs.actConn;
+ inactiveConnections = addedGetRs.inActConn;
+ %>
+ <tr>
+ <td class="center"><%=rsIP%></td>
+ <td class="center"><%=rsPort%></td>
+ <td class="center"><%=rsWeight%></td>
+ <td class="center"><%=activeConnections%></td>
+ <td class="point"><%=inactiveConnections%></td>
+ </tr>
+ <%
+ }
+ %>
+
+ <%
+ }catch(NullPointerException e){
+ MessageView error = new MessageView(41406, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ }
+ %>
+ </table>
+ </fieldset>
+ <%
+ }
+ else {
+ %>
+ <p class="error">No VirtualService List</p>
+ <%
+ }
+ }
+ else{
+ %>
+ <p class="error">No VirtualService List</p>
+ <%
+ }
+ %>
+
+ <h2>Monitor</h2>
+ <fieldset class="">
+ <legend>Monitor : Current Status</legend>
+ <table class="infotable">
+ <tr>
+ <th>
+ <label for="checkTimeOut">CheckTimeOut</label>
+ </th>
+ <th>
+ <label for="negotiateTimeOut">NegotiateTimeOut</label>
+ </th>
+ <th>
+ <label for="checkInterval">CheckInterval</label>
+ </th>
+ <th>
+ <label for="checkCount">CheckCount</label>
+ </th>
+ <th>
+ <label for="quiescent">Quiescent</label>
+ </th>
+ </tr>
+ <tr>
+ <td class="center"><%=checkTimeout%></td>
+ <td class="center"><%=negotiateTimeOut%></td>
+ <td class="center"><%=checkInterval%></td>
+ <td class="center"><%=checkCount%></td>
+ <td class="center"><%=quiescent%></td>
+ </tr>
+ </table>
+ </fieldset>
+
+
+ <%
+ if (snmp.status == SnmpAgentStatus.CONNECTING) {
+ %>
+ <h2>SNMP Agent</h2>
+ <fieldset class="">
+ <legend>SNMP Agent : Current Status</legend>
+ <table class="infotable">
+ <tr>
+ <th>
+ <label for="queryInterval">Query Interval</label>
+ </th>
+ </tr>
+ <tr>
+ <td class="center"><%=query %> <%=queryUnit %></td>
+ </tr>
+ </table>
+ </fieldset>
+ <%
+ }
+ %>
+
+ <%
+ if ( rep.replicationMode != ReplicationStatus.SINGLE ){
+ %>
+ <h2>Replication</h2>
+ <fieldset class="">
+ <legend>Replication : Current Status</legend>
+ <table class="infotable">
+ <tr>
+ <th>
+ <label for="Replication Mode">Replication Mode</label>
+ </th>
+ <th>
+ <label for="Interval">Interval</label>
+ </th>
+ </tr>
+ <tr>
+ <td class="center"><%=printRepStatus %></td>
+ <td class="center"><%=rep.interval %> [µsec]</td>
+ </tr>
+ </table>
+ </fieldset>
+ <%
+ }
+ %>
+
+ </div>
+
+</body>
+</html>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*,java.util.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41407, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+
+ /*
+ * get l7vsadm data from L7guiFramework
+ */
+ L7guiFramework framework = new L7guiFramework();
+ L7vsAdmData admDataList = framework.getAdmData();
+ if (admDataList == null) {
+ MessageView error = new MessageView(41408, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+
+ /*
+ * get l7directrod.cf data
+ */
+ DirectorData dd = framework.getDirectorData();
+ if (dd == null) {
+ MessageView error = new MessageView(41409, LogCategorySet.GUI_IO_FILE,
+ Message.DIRECTOR_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get cluster status
+ */
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41410, LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%= cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico"/>
+
+ <title>UltraMonkey-L7 Current Status</title>
+
+ </head>
+
+ <body class="normal">
+ <div id="content">
+
+ <h1>VirtualService Current Status</h1>
+<%
+ if ( (cd.self_status.equals(ClusterStatus.ACTIVE)) || (cd.self_status.equals(ClusterStatus.SINGLE) )){
+
+ MessageView mv = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String message = null;
+ int errno = 0;
+ String category = null;
+
+ if (mv != null) {
+ message = mv.getMessage();
+ errno = mv.getErrno();
+ category = mv.getCategory();
+ if ( message != null){
+ out.println("<p class=\"error\">[" + category + "-" + errno + "] </p>" );
+ out.println("<p class=\"error\">" + message + "</p>");
+ }
+ session.setAttribute(SessionKeys.RESULT_MESSAGE,null);
+ }
+ %>
+
+
+ <%
+ MessageView mvCommand = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE);
+ String commandMessage = null;
+ int commandErrno = 0;
+ String commandCategory = null;
+ if (mvCommand != null) {
+ commandMessage = mvCommand.getMessage();
+ commandErrno = mvCommand.getErrno();
+ commandCategory = mvCommand.getCategory();
+ if ( commandMessage != null ){
+ out.println("<p class=\"success\">[" + commandCategory + "-" + commandErrno + "] </p>" );
+ out.println("<p class=\"success\">" + commandMessage + "</p>");
+ }
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE,null);
+ }
+ %>
+
+ <form method="post" action="VSRemoveServlet" name="vs_info" id="vs_info">
+ <%
+ /*
+ * get VirtualService data from L7guiFramework
+ */
+ Vector<VirtualSetting> vsList = new Vector<VirtualSetting>();
+ vsList = admDataList.virtualSettings;
+ ArrayList<String> vsNameList = new ArrayList<String>();
+ vsNameList.clear();
+
+ String vsIp = null;
+ String vsPort = null;
+ String vsProtomod = null;
+ String vsOption = null;
+ String vsSchedule = null;
+ String rsIP = null;
+ String rsPort = null;
+ int rsWeight = 0;
+ long activeConnections = 0;
+ long inactiveConnections = 0;
+ String vsSorryFlag = null;
+
+ if (vsList.size() > 0) {
+ %>
+ <fieldset>
+ <legend>Virtual Service List</legend>
+ <table class="infotable" cellspacing="0">
+ <tr>
+ <th class="point" rowspan="2">
+ <label for="Remove Modify Check">Remove/<br />Modify CHECK</label>
+ </th>
+ <th class="head" colspan="5">
+ <label for="VirtualService">VirtualService</label>
+ </th>
+ <th class="head" colspan="5">
+ <label for="RealServices">RealServer</label>
+ </th>
+ <th rowspan="2">
+ <label for="SorryFlag">Sorry Flag</label>
+ </th>
+ </tr>
+ <tr>
+ <th>
+ <label for="VirtualIP Address">VirtualIP Address</label>
+ </th>
+ <th>
+ <label for="Port Number">Port Number</label>
+ </th>
+ <th>
+ <label for="Persistence Type">Persistence Type</label>
+ </th>
+ <th>
+ <label for="Module option">Module Option</label>
+ </th>
+ <th class="point">
+ <label for="Scheduler Type">Scheduler Type</label>
+ </th>
+ <th>
+ <label for="RealServer IP Address">IP Address</label>
+ </th>
+ <th>
+ <label for="RealServer Port Number">Port Number</label>
+ </th>
+ <th>
+ <label for="RealServer weight">Weight</label>
+ </th>
+ <th>
+ <label for="ActiveConnections">Active Connections</label>
+ </th>
+ <th class="point">
+ <label for="InactiveConnections">Inactive Connections</label>
+ </th>
+ </tr>
+ <%
+ for (int i = 0; i < vsList.size(); i++) {
+ try {
+ VirtualSetting getVirtualSetting = vsList.get(i);
+
+ vsIp = getVirtualSetting.virtual.host;
+ vsPort = getVirtualSetting.virtual.port;
+ vsProtomod = getVirtualSetting.protomod;
+ vsOption = getVirtualSetting.option;
+ vsSchedule = getVirtualSetting.sched;
+
+ Vector<EndPoint> getRsList =getVirtualSetting.real;
+ int rsNumber = getRsList.size();
+ if ( rsNumber < 0 ){
+ rsNumber = 1;
+ }
+
+ boolean vsSorry = getVirtualSetting.sorryflag;
+
+ if ( (vsIp == null) || (vsProtomod == null) || (vsOption == null) ){
+ MessageView error = new MessageView(41411, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ vsNameList.add(vsIp + ":" + vsPort + ":" + vsProtomod + ":" + vsOption);
+ %>
+
+ <tr>
+ <td class="point" rowspan="<%=rsNumber %>"><input type="radio" name= "vs" value="<%=vsNameList.get(i) %>" /></td>
+ <td class="center" rowspan="<%=rsNumber %>"><%=vsIp%></td>
+ <td class="center" rowspan="<%=rsNumber %>"><%=vsPort%></td>
+ <td class="center" rowspan="<%=rsNumber %>"><%=vsProtomod%></td>
+ <td class="center" rowspan="<%=rsNumber %>"><%=vsOption%></td>
+ <td class="point" rowspan="<%=rsNumber %>"><%=vsSchedule%></td>
+ <%
+ if ( rsNumber < 1 ){
+ %>
+ <td class="center">-</td>
+ <td class="center">-</td>
+ <td class="center">-</td>
+ <td class="center">-</td>
+ <td class="point">-</td>
+ <%
+ }
+ else{
+ EndPoint getRs = getRsList.get(0);
+ rsIP = getRs.host;
+ rsPort = getRs.port;
+ rsWeight = getRs.weight;
+ activeConnections = getRs.actConn;
+ inactiveConnections = getRs.inActConn;
+ %>
+ <td class="center"><%=rsIP%></td>
+ <td class="center"><%=rsPort%></td>
+ <td class="center"><%=rsWeight%></td>
+ <td class="center"><%=activeConnections%></td>
+ <td class="point"><%=inactiveConnections%></td>
+ <%
+ }
+ if(vsSorry == true){
+ vsSorryFlag = "On";
+ }
+ else {
+ vsSorryFlag = "Off";
+ }
+ %>
+ <td class="center" rowspan="<%=rsNumber %>"><%=vsSorryFlag %></td>
+ </tr>
+ <%
+ for ( int j = 1; j < rsNumber; j++ ){
+ EndPoint addedGetRs = getRsList.get(j);
+ rsIP = addedGetRs.host;
+ rsPort = addedGetRs.port;
+ rsWeight = addedGetRs.weight;
+ activeConnections = addedGetRs.actConn;
+ inactiveConnections = addedGetRs.inActConn;
+ %>
+ <tr>
+ <td class="center"><%=rsIP%></td>
+ <td class="center"><%=rsPort%></td>
+ <td class="center"><%=rsWeight%></td>
+ <td class="center"><%=activeConnections%></td>
+ <td class="point"><%=inactiveConnections%></td>
+ </tr>
+ <%
+ }
+ %>
+
+ <%
+ }catch(NullPointerException e){
+ MessageView error = new MessageView(41412, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ }
+ %>
+ </table>
+ </fieldset>
+ <%
+ }
+ %>
+
+ <h2>Add a New VirtualService</h2>
+ <h4>Please push the following button, if you would like to add a new virtualService.</h4><br />
+
+ <input type="button" value="<%= ButtonMode.ADD %>" onclick="location.href='<%=RedirectPages.VS_ADD %>'" />
+
+ <%
+ if (vsList.size() > 0) {
+ %>
+ <h2>Modify a VirtualService</h2>
+ <h4>Please select and push the following button, if you would like to modify a virtualService.</h4><br />
+
+ <input type="button" value="<%= ButtonMode.MODIFY %>" onClick="vs_modify('<%=RedirectPages.VS_MODIFY %>')" />
+
+ <h2>Remove a VirtualService</h2>
+ <h4>Please select and push the following button, if you would like to remove a virtualService.</h4><br />
+
+ <input type="submit" name="button_remove" value="<%=ButtonMode.APPLY %>" onClick="return confirm(remove_vs_apply)" />
+ <%
+ if (dd.autoreload == true) {
+ %>
+ <input type="submit" name="button_remove" value="<%=ButtonMode.SAVE %>" onClick="return confirm(remove_vs_save)" />
+ <%
+ if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) {
+ %>
+ <input type="submit" name="button_remove" value="<%=ButtonMode.SAVESYNC %>" onClick="return confirm(remove_vs_savesync)" />
+ <%
+ }
+ }
+ }
+ %>
+ </form>
+
+ <%
+ }
+ else{
+ response.sendRedirect(RedirectPages.TOPMENU);
+ return;
+
+ }
+ %>
+</div>
+<jsp:include page="menu.jsp" flush="false"/>
+</body>
+</html>
+
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*, java.util.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
+%>
+<%
+
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41413, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+ /*
+ * get user info
+ */
+ UserManager user = UserManager.getInstance();
+ Vector<UserData> userList;
+ try {
+ userList = user.getUserList();
+ }
+ catch(Exception e){
+ MessageView error = new MessageView(41414, LogCategorySet.GUI_IO_FILE,
+ Message.READ_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ if ( userList == null ){
+ MessageView error = new MessageView(41415, LogCategorySet.GUI_IO_FILE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ int userCount = userList.size();
+
+ /*
+ * get Input User Data
+ */
+ UserData inputUser = (UserData)session.getAttribute(SessionKeys.INPUT_USERDATA);
+ if ( inputUser != null ){
+ session.setAttribute(SessionKeys.INPUT_USERDATA, null);
+ }
+
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41416, LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+
+ <title>Add User</title>
+ </head>
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+
+ <div id="content">
+
+ <h1>Add User </h1>
+
+ <% if ( userCount >= 16){
+ %>
+ <p class="error"><%=Message.USER_MAX %></p>
+ <%
+ }
+ else {
+ if (message != null) {
+ %>
+ <p class="error">[<%=category %> - <%=errorNumber %>]</p>
+ <p class="error"><%=errorMessage %></p>
+ <%
+ }
+ %>
+
+ <form method="post" action="UserAddServlet">
+
+ <fieldset>
+ <legend>Add User Info</legend>
+ <table class="status">
+ <tr>
+ <th>
+ <label for="userId">User ID</label>
+ </th>
+ <td>
+ <% if ( (inputUser != null) && (inputUser.userName != null) ){ %>
+ <input type="text" name="userId" value="<%=inputUser.userName %>" size="20" maxlength="16">
+ <%}
+ else {%>
+ <input type="text" name="userId" size="20" maxlength="16">
+ <%} %>
+ </td>
+ <td>
+ <p class="item">Required Field</p>
+ <p class="required">Between 1 and 16 one-byte characters in English</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="description">Description</label>
+ </th>
+ <td>
+ <% if ( (inputUser != null) && (inputUser.description != null) ){ %>
+ <input type="text" name="description" value="<%=inputUser.description %>" size="20" maxlength="64">
+ <% }
+ else{
+ %>
+ <input type="text" name="description" size="20" maxlength="64">
+ <%
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 64 one-byte characters in English</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="password">Password</label>
+ </th>
+ <td>
+ <input type="password" name="new1_passwd" size="20" maxlength="16">
+ </td>
+ <td>
+ <p class="item">Required Field</p>
+ <p class="required">Between 6 and 16 one-byte characters in English</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="password">Re-type Password</label>
+ </th>
+ <td>
+ <input type="password" name="new2_passwd" size="20" maxlength="16">
+ </td>
+ <td>
+ <p class="item">Required Field</p>
+ <p class="required">Between 6 and 16 one-byte characters in English</p>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+
+ <br>
+ <input type="submit" name="button" value="<%= ButtonMode.ADD %>" onClick="return confirm(user_add)" />
+ <input type = "Reset" value = "Clear">
+
+ </form>
+ <%
+ }
+ %>
+ </div>
+ </body>
+</html>
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41417,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.RESULT_MESSAGE);
+
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41418,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Failed : Add User</title>
+</head>
+
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false" />
+
+
+
+<div id="content">
+<h1 class="title">Failed : Add User</h1>
+
+<%
+ if (errorMessage != null) {
+ out.println("<h2>Error Reason :</h2>");
+ out.println("<p class=\"error\"> [" + category + " - " + errorNumber + "] </p>");
+ out.println("<p class=\"error\">" + errorMessage + "</p>");
+ }
+%>
+</div>
+</body>
+</html>
+
+
+
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41419,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.RESULT_MESSAGE);
+
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41420,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Failed : Delete User</title>
+</head>
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false" />
+
+<div id="content">
+<h1 class="title">Failed : Delete User</h1>
+
+<%
+ if (errorMessage != null) {
+ out.println("<h2>Error Reason :</h2>");
+ out.println("<p class=\"error\"> [" + category + " - " + errorNumber + "] </p>");
+ out.println("<p class=\"error\">" + errorMessage + "</p>");
+ }
+%>
+</div>
+</body>
+</html>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*,java.util.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
+%>
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41421, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+
+ /*
+ * get self info
+ */
+ UserData currentUser = (UserData) session.getAttribute(SessionKeys.LOGIN_SESSION);
+ if ( currentUser == null) {
+ MessageView error = new MessageView(41422, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ String currentUserName = currentUser.userName;
+ if (currentUserName == null){
+ MessageView error = new MessageView(41423, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get user info
+ */
+ UserManager user = UserManager.getInstance();
+ Vector<UserData> userList;
+ try {
+ userList = user.getUserList();
+ }
+ catch(Exception e){
+ MessageView error = new MessageView(41424, LogCategorySet.GUI_IO_FILE,
+ Message.READ_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ if ( userList == null ){
+ MessageView error = new MessageView(41425, LogCategorySet.GUI_IO_FILE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+ String resultClass = "success";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+ if (errorMessage.equals(Message.USER_REMOVE_SELECT_ERROR)) {
+ resultClass = "error";
+ }
+
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41426, LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+ <html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%= cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico"/>
+
+ <title>Manage Users</title>
+ </head>
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+
+ <div id="content">
+
+ <h1>Manage Users </h1>
+ <%
+ if ( (message != null) && (errorMessage != null)) {
+ %>
+ <p class="<%=resultClass %>">[<%=category%> - <%=errorNumber%>]</p>
+ <p class="<%=resultClass %>"><%=errorMessage%></p>
+ <%
+ }
+ %>
+
+
+
+ <form method="post" action="UserRemoveServlet" name="user_remove">
+ <fieldset>
+ <legend>Current User list</legend>
+
+ <table class="infotable" cellspacing="0">
+ <thead>
+ <tr><th>Delete CHECK</th><th>User ID</th><th>Description</th></tr>
+ </thead>
+ <tbody>
+ <%
+ for ( UserData userInfo : userList){
+ out.println("<tr><td class=\"center\">");
+ if ( !userInfo.userName.equals(currentUserName) )
+ out.println("<input type=\"checkbox\" name=\"ck_user\" value=\"" + userInfo.userName + "\"/>");
+ out.println("</td>");
+ out.println("<td>"+ userInfo.userName + "</td>");
+ out.println("<td>");
+ if (userInfo.description != null){
+ out.println(userInfo.description);
+ }
+ out.println("</td></tr>");
+ }
+ %>
+ </tbody>
+ </table>
+ </fieldset>
+
+ <%
+ int userCount = userList.size();
+ if (userCount < 16){
+ %>
+ <h2>Add a New User</h2>
+ <h4>Please push the following button, if you add a new user.</h4><br />
+ <input type="button" value="<%= ButtonMode.ADD %>" onClick="location.href='<%= RedirectPages.USER_ADD %>'" />
+ <%
+ }
+ %>
+
+ <h2>Modify User</h2>
+ <h4>Please push the following button, if you modify your account.</h4><br />
+ <input type="button" value="<%= ButtonMode.MODIFY %>" onClick="location.href='<%= RedirectPages.USER_MODIFY %>'" />
+
+ <%
+ if (userCount > 1) {
+ %>
+ <h2>Delete Users</h2>
+ <h4>Please select and push the following button, if you delete user.</h4><br />
+ <input type="submit" name="button" value="<%= ButtonMode.DELETE %>" onClick="return confirm(user_delete)" />
+ <%
+ }
+ %>
+ </form>
+
+ </div>
+ </body>
+</html>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*, org.ultramonkey.l7.controller.*, org.ultramonkey.l7.view.*, java.util.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%
+
+ /*
+ * check session
+ */
+ if (session.isNew()) {
+ MessageView error = new MessageView(41427, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = null;
+ int errorNumber = 0;
+ String category = "";
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+ /*
+ * get post user data
+ */
+ UserData user = (UserData)session.getAttribute(SessionKeys.INPUT_USERDATA);
+ if ( user != null ){
+ session.setAttribute(SessionKeys.INPUT_USERDATA, null);
+ }
+
+ if (user == null ){
+ user = (UserData)session.getAttribute(SessionKeys.LOGIN_SESSION);
+ if (user == null){
+ MessageView error = new MessageView(41428, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ }
+
+ if (user.description == null){
+ user.description = "";
+ }
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41429, LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%= cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico"/>
+
+ <title>Modify User</title>
+
+
+ </head>
+
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+
+ <div id="content">
+
+ <h1>Modify User</h1>
+
+ <%
+ if ((message != null) || (errorMessage != null)){
+ %>
+ <p class="error">[ <%=category %> - <%=errorNumber %>]</p>
+ <p class="error"><%= errorMessage %></p>
+ <%
+ }
+ %>
+
+ <form method="post" action="UserModServlet">
+
+ <fieldset>
+ <legend>Modify User Info</legend>
+ <table class="status">
+ <tr>
+ <th>
+ <label for="description">Description</label>
+ </th>
+ <td>
+ <input type="text" name="description" value="<%=user.description %>" size="32" maxlength="64">
+ </td>
+ <td>
+ <p class="required">Up to 64 one-byte characters in English</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="current_password">Current Password</label>
+ </th>
+ <td>
+ <input type="password" name="password" size="18" maxlength="16">
+ </td>
+ <td>
+ <p class="item">Required Field</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="new_password">New Password</label>
+ </th>
+ <td>
+ <input type="password" name="new1_passwd" size="18" maxlength="16">
+ </td>
+ <td>
+ <p class="item">Required Field</p>
+ <p class="required">Up to 16 one-byte characters in English</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="re-type_new_password">Re-type New Password</label>
+ </th>
+ <td>
+ <input type="password" name="new2_passwd" size="18" maxlength="16">
+ </td>
+ <td>
+ <p class="item">Required Field</p>
+ <p class="required">Up to 16 one-byte characters in English</p>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+
+
+ <br />
+
+ <input type="submit" name="button" value="<%= ButtonMode.CHANGE %>" onClick="return confirm(user_modify)" />
+ <input type="reset" value="Clear" />
+ </form>
+
+ </div>
+</body>
+</html>
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41430,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.RESULT_MESSAGE);
+
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41431,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Failed : Modify User</title>
+</head>
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false" />
+
+<div id="content">
+<h1 class="title">Failed : Modify User</h1>
+<%
+ /*
+ * get user id
+ */
+ UserData user = (UserData) session.getAttribute(SessionKeys.LOGIN_SESSION);
+ String username = "";
+ if (user != null) {
+ username = user.userName;
+ } else {
+ MessageView message_userid = new MessageView(41432,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.UNEXPECTED_ERROR);
+ session
+ .setAttribute(SessionKeys.RESULT_MESSAGE,
+ message_userid);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ if ((username != null) && (errorMessage != null)) {
+ out.println("<h2>Failed To Modify " + username
+ + "'s User Info.</h2>");
+ out.println("<h2>Please try agein.</h2><br />");
+ out.println("<h2> Error Reason : </h2>");
+ out.println("<p class=\"error\"> [" + category + " - " + errorNumber + "] </p>");
+ out.println("<p class=\"error\">" + errorMessage + "</p>");
+ } else {
+ out.println("<h2>Failed To Modify User Info.</h2>");
+ out.println("<h2>Please try agein.</h2><br />");
+ }
+%>
+</div>
+</body>
+</html>
+
+
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41433,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.RESULT_MESSAGE);
+
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41434,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+
+ <title>Succeeded : Modify User</title>
+</head>
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false" />
+
+<div id="content">
+<h1 class="title">Succeeded : Modify User</h1>
+
+<%
+ /*
+ * get user id
+ */
+ UserData user = new UserData();
+ user = (UserData) session.getAttribute(SessionKeys.LOGIN_SESSION);
+ String username = "";
+
+ if (user != null) {
+ username = user.userName;
+ } else {
+ MessageView message_userid = new MessageView(41435,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.UNEXPECTED_ERROR);
+ session
+ .setAttribute(SessionKeys.RESULT_MESSAGE,
+ message_userid);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ if (username != null) {
+ out.println("<h2>Succeeded to modify " + username
+ + "'s User Info.</h2>");
+ } else {
+ out.println("<h2>Succeeded to modify User Info.</h2>");
+ }
+%>
+</div>
+</body>
+</html>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*, java.util.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41436, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+ /*
+ * get validation error message
+ */
+ HashMap<String,String> errMessage = (HashMap<String,String>) session.getAttribute(SessionKeys.INVALID_MESSAGE);
+ session.setAttribute(SessionKeys.INVALID_MESSAGE,null);
+
+ /*
+ * get previous input value
+ */
+ L7guiFramework framework = new L7guiFramework();
+ VirtualSetting vs = (VirtualSetting) session.getAttribute(SessionKeys.INPUT_VS);
+ if (vs != null) {
+ session.setAttribute(SessionKeys.INPUT_VS, null);
+ }
+
+ /*
+ * get l7directrod.cf data
+ */
+ DirectorData dd = framework.getDirectorData();
+ if (dd == null) {
+ MessageView error = new MessageView(41437, LogCategorySet.GUI_IO_FILE,
+ Message.DIRECTOR_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+
+ /*
+ * get cluster status
+ */
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41438, LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+%>
+
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+
+ <title>Add VirtualService</title>
+ </head>
+
+ <body class="normal">
+ <jsp:include page="menu.jsp" flush="false"/>
+ <div id="content">
+ <h1 class="title">Add a VirtualService</h1>
+<%
+if ( (cd.self_status.equals(ClusterStatus.ACTIVE)) || (cd.self_status.equals(ClusterStatus.SINGLE) )){
+
+ if ( (message != null) && (errorMessage != null)) {
+%>
+
+<p class="error">[<%=category %> - <%=errorNumber %>]</p>
+<p class="error"><%=errorMessage %></p>
+
+<%
+ }
+%>
+
+ <h2> VirtualService Info</h2>
+ <form method="post" action="VSAddServlet" name="vs_add">
+
+
+ <fieldset>
+ <legend>Basic Settings</legend>
+
+ <table class="status">
+ <tr>
+ <th>
+ <label for="ip">Virtual IP address</label>
+ </th>
+ <td>
+ <input type="text" id="ip" name="vip" value="<%
+ if ( null != vs )
+ out.println(vs.virtual.host); %>" maxlength="15" />
+ <%
+ if ( null != errMessage ){
+ String invalidMessage = errMessage.get("vip");
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="item">Required Field</p>
+ <p class="required">[0-255].[0-255].[0-255].[0-255]</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="port">Port Number</label>
+ </th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("port");
+ }
+
+ if ( (vs == null) || (vs.virtual.port == null) ){
+
+ out.println("<input type=\"text\" id=\"port\" value=\"\" name=\"port\" />");
+ }
+ else{
+ out.println("<input type=\"text\" id=\"port\" value=\"" + vs.virtual.port + "\"name=\"port\" />");
+ }
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="item">Required Field</p>
+ <p class="required">1-65535, service name</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="protomod">Persistence Type</label>
+ </th>
+ <td>
+ <select id="protomod" name="protomod">
+ <option value="cinsert"<%
+ if ( (vs != null ) && (vs.protomod.equals("cinsert")) )
+ out.print(" selected");
+ %>>Cookie Insert</option>
+ <option value="url"<%
+ if ( (vs != null ) && (vs.protomod.equals("url")) )
+ out.print(" selected");
+ %>>URL Pattern</option>
+ <option value="sslid"<%
+ if ( (vs != null ) && (vs.protomod.equals("sslid")) )
+ out.print(" selected");
+ %>>SSL Session ID</option>
+ <option value="sessionless"<%
+ if ( (vs != null ) && (vs.protomod.equals("sessionless")) )
+ out.print(" selected");
+ %>>Sessionless</option>
+ </select>
+ <%
+ if ( null != errMessage ){
+ String invalidMessage = errMessage.get("protomod");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="item">Required Field</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="option">Persistence option</label>
+ </th>
+ <td>
+ <input type="text" id="option" name="option" value="<%
+ if ( null != vs )
+ out.println(vs.option); %>" maxlength="127" />
+ <%
+ if ( null != errMessage ){
+ String invalidMessage = errMessage.get("option");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 127 one-byte characters in English</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="sched">Scheduler Type</label>
+ </th>
+ <td>
+ <select id="sched" name="sched">
+ <option value="rr"<%
+ if ( (vs != null ) && (vs.sched.equals("rr")) )
+ out.print(" selected");
+ %>>Round Robin</option>
+ <option value="wrr"<%
+ if ( (vs != null ) && (vs.sched.equals("wrr")) )
+ out.print(" selected");
+ %>>Weighted Round Robin</option>
+ <option value="lc"<%
+ if ( (vs != null ) && (vs.sched.equals("lc")) )
+ out.print(" selected");
+ %>>Least Connection</option>
+ </select>
+ <%
+ if ( null != errMessage ){
+ String invalidMessage = errMessage.get("sched");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required"></p>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+ <fieldset class="">
+ <legend>Advanced Settings</legend>
+ <table class="status">
+ <tr>
+ <th>
+ <label for="qos_srv">QoS (per Virtual Service)</label>
+ </th>
+ <td>
+ <% {
+ String invalidMessage = null;
+ int unit_s = 0;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("qos_service");
+ }
+ if ( (vs == null) || ( ( 0 == vs.qosservice ) && ( null != invalidMessage ) ) ){
+ out.println("<input type=\"text\" id=\"qos_srv\" value=\"\" name=\"qos_service\" size=\"3\" maxlength=\"3\" />");
+ }
+ else{
+ if ( null == invalidMessage ){
+ while ( (vs != null) && (vs.qosservice >= 1000) ) {
+ vs.qosservice /= 1000;
+ unit_s++;
+ }
+ }
+ out.println("<input type=\"text\" id=\"qos_srv\" value=\"" + vs.qosservice + "\"name=\"qos_service\" size=\"3\" maxlength=\"3\" />");
+ }
+ %>
+ <select id="qos_srv" name="qos_service_unit">
+ <option value="bps"<%
+ if ( (vs != null) && (unit_s == 0) )
+ out.print(" selected");
+ %>>bps</option>
+ <option value="Kbps"<%
+ if ( (vs != null) && (unit_s == 1) )
+ out.print(" selected");
+ %>>Kbps</option>
+ <option value="Mbps"<%
+ if ( (vs != null) && (unit_s == 2) )
+ out.print(" selected");
+ %>>Mbps</option>
+ <option value="Gbps"<%
+ if ( (vs != null) && (unit_s == 3) )
+ out.print(" selected");
+ %>>Gbps</option>
+ </select>
+ <%
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">0-999(bps/Kbps/Mbps/Gbps)</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="qos_conn">QoS (per Client)</label>
+ </th>
+ <td>
+ <% {
+ String invalidMessage = null;
+ int unit_c = 0;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("qos_conn");
+ }
+ if ( (vs == null) || ( ( 0 == vs.qosclient ) && ( null != invalidMessage ) ) ){
+ out.print("<input type=\"text\" id=\"qos_conn\" value=\"\" name=\"qos_conn\" size=\"3\" maxlength=\"3\" />");
+ }
+ else{
+ if ( null == invalidMessage ){
+ while ( (vs != null) && (vs.qosclient >= 1000) ) {
+ vs.qosclient /= 1000;
+ unit_c++;
+ }
+ }
+ out.print("<input type=\"text\" id=\"qos_conn\" value=\"" + vs.qosclient + "\" name=\"qos_conn\" size=\"3\" maxlength=\"3\" />");
+ }
+ %>
+ <select id="qos_conn" name="qos_conn_unit">
+ <option value="bps"<%
+ if ( (vs != null) && (unit_c == 0) )
+ out.print(" selected");
+ %>>bps</option>
+ <option value="Kbps"<%
+ if ( (vs != null) && (unit_c == 1) )
+ out.print(" selected");
+ %>>Kbps</option>
+ <option value="Mbps"<%
+ if ( (vs != null) && (unit_c == 2) )
+ out.print(" selected");
+ %>>Mbps</option>
+ <option value="Gbps"<%
+ if ( (vs != null) && (unit_c == 3) )
+ out.print(" selected");
+ %>>Gbps</option>
+ </select>
+ <%
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">0-999(bps/Kbps/Mbps/Gbps)</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="max_conn">Max Connections</label>
+ </th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("max_conn");
+ }
+ if ( (vs == null) || ( ( 0 == vs.maxconn ) && ( null != invalidMessage ) ) ){
+ out.println("<input type=\"text\" id=\"max_conn\" value=\"\" name=\"max_conn\" maxlength=\"6\" />");
+ }
+ else{
+ out.println("<input type=\"text\" id=\"max_conn\" value=\"" + vs.maxconn + "\" name=\"max_conn\" maxlength=\"6\" />");
+ }
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">0-100000<br>Note : "0" means "Unlimited"</p>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+
+ <fieldset class="">
+ <legend>Monitor Settings</legend>
+ <p class="caution"> <img src="images/exclamation3.gif" alt="Caution!!" width="16" height="14" align="middle">
+ Disable Area when you push "Apply" button.</p>
+ <table class="status">
+ <tr>
+ <th>
+ <label for="timeout">Check Timeout</label>
+ </th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("timeout");
+ }
+ if ( (vs == null) || (0 == vs.timeout) ){
+ if ( dd.autoreload == true ) {
+ out.println("<input type=\"text\" id=\"timeout\" value=\"\" name=\"timeout\" maxlength=\"10\" />");
+ }
+ else {
+ out.println("<input class=\"read\" readonly type=\"text\" id=\"timeout\" value=\"\" name=\"timeout\" maxlength=\"10\" />");
+ }
+ }
+ else {
+ if ( dd.autoreload == true ) {
+ out.println("<input type=\"text\" id=\"timeout\" value=\"" + vs.timeout + "\" name=\"timeout\" maxlength=\"10\" />");
+ }
+ else {
+ out.println("<input class=\"read\" readonly type=\"text\" id=\"timeout\" value=\"\" name=\"timeout\" maxlength=\"10\" />");
+ }
+ }
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">1-2147483647(sec)</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="check_type">Check Type</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true ) {
+ %>
+ <input type="text" id="check_type" value="<%
+ if ( null != vs )
+ out.println(vs.checktype); %>" name="check_type" maxlength="9" />
+ <%
+ }
+ else{
+ %>
+ <input class="read" readonly type="text" id="check_type" value="<%
+ if ( null != vs )
+ out.println(vs.checktype); %>" name="check_type" maxlength="9" />
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("check_type");
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Any Of The Following<br>negotiate, connect, ping, off, on, 0-9</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="check_service">Check Service</label>
+ </th>
+ <td>
+ <% if ( dd.autoreload == true ) {%>
+ <select id="check_service" name="check_service">
+ <option value=""<%
+ if ( ( null != vs ) && (vs.service.equals("")) )
+ out.print(" selected");
+ %>></option>
+ <option value="ftp"<%
+ if ( ( null != vs ) && (vs.service.equals("ftp")) )
+ out.print(" selected");
+ %>>FTP</option>
+ <option value="smtp"<%
+ if ( ( null != vs ) && (vs.service.equals("smtp")) )
+ out.print(" selected");
+ %>>SMTP</option>
+ <option value="dns"<%
+ if ( ( null != vs ) && (vs.service.equals("dns")))
+ out.print(" selected");
+ %>>DNS</option>
+ <option value="http"<%
+ if ( ( null != vs ) && (vs.service.equals("http")) )
+ out.print(" selected");
+ %>>HTTP</option>
+ <option value="pop"<%
+ if ( ( null != vs ) && (vs.service.equals("pop")) )
+ out.print(" selected");
+ %>>POP</option>
+ <option value="nntp"<%
+ if ( ( null != vs ) && (vs.service.equals("nntp")) )
+ out.print(" selected");
+ %>>NNTP</option>
+ <option value="imap"<%
+ if ( ( null != vs ) && (vs.service.equals("imap")) )
+ out.print(" selected");
+ %>>IMAP</option>
+ <option value="ldap"<%
+ if ( ( null != vs ) && (vs.service.equals("ldap")) )
+ out.print(" selected");
+ %>>LDAP</option>
+ <option value="https"<%
+ if ( ( null != vs ) && (vs.service.equals("https")) )
+ out.print(" selected");
+ %>>HTTPS</option>
+ <option value="mysql"<%
+ if ( ( null != vs ) && (vs.service.equals("mysql")) )
+ out.print(" selected");
+ %>>MySQL</option>
+ <option value="pgsql"<%
+ if ( ( null != vs ) && (vs.service.equals("pgsql")) )
+ out.print(" selected");
+ %>>PostgreSQL</option>
+ <option value="sip"<%
+ if ( ( null != vs ) && (vs.service.equals("sip")) )
+ out.print(" selected");
+ %>>SIP</option>
+ <option value="none"<%
+ if ( ( null != vs ) && (vs.service.equals("none")) )
+ out.print(" selected");
+ %>>None</option>
+ </select>
+ <%}
+ else
+ {
+ %>
+ <select class="read" disabled id="check_service" name="check_service">
+ <option value=""<%
+ if ( ( null != vs ) && (vs.service.equals("")) )
+ out.print(" selected");
+ %>></option>
+ <option value="ftp"<%
+ if ( ( null != vs ) && (vs.service.equals("ftp")) )
+ out.print(" selected");
+ %>>FTP</option>
+ <option value="smtp"<%
+ if ( ( null != vs ) && (vs.service.equals("smtp")) )
+ out.print(" selected");
+ %>>SMTP</option>
+ <option value="dns"<%
+ if ( ( null != vs ) && (vs.service.equals("dns")))
+ out.print(" selected");
+ %>>DNS</option>
+ <option value="http"<%
+ if ( ( null != vs ) && (vs.service.equals("http")) )
+ out.print(" selected");
+ %>>HTTP</option>
+ <option value="pop"<%
+ if ( ( null != vs ) && (vs.service.equals("pop")) )
+ out.print(" selected");
+ %>>POP</option>
+ <option value="nntp"<%
+ if ( ( null != vs ) && (vs.service.equals("nntp")) )
+ out.print(" selected");
+ %>>NNTP</option>
+ <option value="imap"<%
+ if ( ( null != vs ) && (vs.service.equals("imap")) )
+ out.print(" selected");
+ %>>IMAP</option>
+ <option value="ldap"<%
+ if ( ( null != vs ) && (vs.service.equals("ldap")) )
+ out.print(" selected");
+ %>>LDAP</option>
+ <option value="https"<%
+ if ( ( null != vs ) && (vs.service.equals("https")) )
+ out.print(" selected");
+ %>>HTTPS</option>
+ <option value="mysql"<%
+ if ( ( null != vs ) && (vs.service.equals("mysql")) )
+ out.print(" selected");
+ %>>MySQL</option>
+ <option value="pgsql"<%
+ if ( ( null != vs ) && (vs.service.equals("pgsql")) )
+ out.print(" selected");
+ %>>PostgreSQL</option>
+ <option value="sip"<%
+ if ( ( null != vs ) && (vs.service.equals("sip")) )
+ out.print(" selected");
+ %>>SIP</option>
+ <option value="none"<%
+ if ( ( null != vs ) && (vs.service.equals("none")) )
+ out.print(" selected");
+ %>>None</option>
+ </select>
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("check_service");
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required"></p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="quiescent">Quiescent</label>
+ </th>
+ <td>
+ <%if (dd.autoreload == true) { %>
+ <select id="quiescent" name="quiescent">
+ <option value=""<%
+ if ( ( null != vs ) && (vs.quiescent.equals("")) )
+ out.print(" selected");
+ %>></option>
+ <option value="yes"<%
+ if ( ( null != vs ) && (vs.quiescent.equals("yes")) )
+ out.print(" selected");
+ %>>Yes</option>
+ <option value="no"<%
+ if ( ( null != vs ) && (vs.quiescent.equals("no")) )
+ out.print(" selected");
+ %>>No</option>
+ </select>
+ <%
+ }
+ else
+ {
+ %>
+ <select class="read" disabled id="quiescent" name="quiescent">
+ <option value=""<%
+ if ( ( null != vs ) && (vs.quiescent.equals("")) )
+ out.print(" selected");
+ %>></option>
+ <option value="yes"<%
+ if ( ( null != vs ) && (vs.quiescent.equals("yes")) )
+ out.print(" selected");
+ %>>Yes</option>
+ <option value="no"<%
+ if ( ( null != vs ) && (vs.quiescent.equals("no")) )
+ out.print(" selected");
+ %>>No</option>
+ </select>
+
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("quiescent");
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Default : No</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="down_callback">Real Server Down Callback</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true ) {
+ %>
+ <input type="text" id="down_callback" value="<%
+ if ( null != vs )
+ out.println(vs.downcallback); %>" name="down_callback" maxlength=\"127\" />
+ <%
+ }
+ else{
+ %>
+ <input class="read" readonly type="text" id="down_callback" value="<%
+ if ( null != vs )
+ out.println(vs.downcallback); %>" name="down_callback" maxlength=\"127\" />
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("down_callback");
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 127 one-byte characters in English<br>Be effctive only if CheckService : HTTP, HTTPS, LDAP, MySQL, PostgreSQL, SIP, None</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="up_callback">Real Server Up Callback</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true ) {
+ %>
+ <input type="text" id="up_callback" value="<%
+ if ( null != vs )
+ out.println(vs.upcallback); %>" name="up_callback" maxlength=\"127\" />
+ <%
+ }
+ else{
+ %>
+ <input class="read" readonly type="text" id="up_callback" value="<%
+ if ( null != vs )
+ out.println(vs.upcallback); %>" name="up_callback" maxlength=\"127\" />
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("up_callback");
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 127 one-byte characters in English</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="check_port">Check Port</label>
+ </th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ){
+ invalidMessage = errMessage.get("check_port");
+ }
+ if ( (vs == null) || (0 == vs.checkport) ){
+ if ( dd.autoreload == true ) {
+ out.println("<input type=\"text\" id=\"check_port\" value=\"\" name=\"check_port\" maxlength=\"5\" />");
+ }
+ else{
+ out.println("<input class=\"read\" readonly type=\"text\" id=\"check_port\" value=\"\" name=\"check_port\" maxlength=\"5\" />");
+ }
+ }
+ else{
+ if ( dd.autoreload == true ) {
+ out.println("<input type=\"text\" id=\"check_port\" value=\"" + vs.checkport + "\" name=\"check_port\" maxlength=\"5\" />");
+ }
+ else{
+ out.println("<input class=\"read\" readonly type=\"text\" id=\"check_port\" value=\"" + vs.checkport + "\" name=\"check_port\" maxlength=\"5\" />");
+ }
+ }
+ if ( null != invalidMessage ) {
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">1-65535</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="request">Request Path</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true ) {
+ %>
+ <input type="text" id="request" value="<%
+ if ( null != vs )
+ out.println(vs.request); %>" name="request" maxlength=\"127\" />
+ <%
+ }
+ else{
+ %>
+ <input class="read" readonly type="text" id="request" value="<%
+ if ( null != vs )
+ out.println(vs.request); %>" name="request" maxlength=\"127\" />
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("request");
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 127 one-byte characters in English<br>Be effctive only if CheckService : HTTP, HTTPS, LDAP, MySQL, PostgreSQL, SIP, None</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="receive">Receive String</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true ) {
+ %>
+ <input type="text" id="receive" value="<%
+ if ( null != vs )
+ out.println(vs.receive); %>" name="receive" maxlength=\"127\" />
+ <%
+ }
+ else {
+ %>
+ <input class="read" readonly type="text" id="receive" value="<%
+ if ( null != vs )
+ out.println(vs.receive); %>" name="receive" maxlength=\"127\" />
+
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("receive");
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 127 one-byte characters in English<br>Be effctive only if CheckService : HTTP, HTTPS, LDAP, FTP, DNS</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="method">HTTP Method</label>
+ </th>
+ <td>
+ <% if ( dd.autoreload == true ){
+ %>
+ <select id="method" name="method">
+ <option value=""<%
+ if ( ( vs != null ) && (vs.httpmethod.equals("")) )
+ out.print(" selected");
+ %>></option>
+ <option value="GET"<%
+ if ( ( vs != null ) && (vs.httpmethod.equals("GET")) )
+ out.print(" selected");
+ %>>GET</option>
+ <option value="HEAD"<%
+ if ( ( vs != null ) && (vs.httpmethod.equals("HEAD")) )
+ out.print(" selected");
+ %>>HEAD</option>
+ </select>
+ <%
+ }
+ else
+ {
+ %>
+ <select class="read" disabled id="method" name="method">
+ <option value=""<%
+ if ( ( vs != null ) && (vs.httpmethod.equals("")) )
+ out.print(" selected");
+ %>></option>
+ <option value="GET"<%
+ if ( ( vs != null ) && (vs.httpmethod.equals("GET")) )
+ out.print(" selected");
+ %>>GET</option>
+ <option value="HEAD"<%
+ if ( ( vs != null ) && (vs.httpmethod.equals("HEAD")) )
+ out.print(" selected");
+ %>>HEAD</option>
+ </select>
+
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("method");
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Be effctive only if CheckService : HTTP, HTTPS</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="virtual_host">Virtual Host</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true ) {
+ %>
+ <input type="text" id="virtual_host" value="<%
+ if ( null != vs )
+ out.println(vs.virtualhost); %>" name="virtual_host" maxlength=\"127\" />
+ <%
+ }
+ else{
+ %>
+ <input class="read" readonly type="text" id="virtual_host" value="<%
+ if ( null != vs )
+ out.println(vs.virtualhost); %>" name="virtual_host" maxlength=\"127\" />
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("virtual_host");
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 127 one-byte characters in English<br>Be effctive only if CheckService : HTTP, HTTPS</p>
+ </td>
+ </tr>
+
+ <tr>
+ <th>
+ <label for="login_user">Login Username</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true ) {
+ %>
+ <input type="text" id="login_user" value="<%
+ if ( null != vs )
+ out.println(vs.login); %>" name="login_user" maxlength=\"32\" />
+ <%
+ }
+ else{
+ %>
+ <input class="read" readonly type="text" id="login_user" value="<%
+ if ( null != vs )
+ out.println(vs.login); %>" name="login_user" maxlength=\"32\" />
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("login_user");
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 32 one-byte characters in English<br>Followings : Effctive only when CheckService is FTP, POP, IMAP, MySQL, PostgreSQL, and SIP</p>
+ </td>
+ </tr>
+
+
+
+ <tr>
+ <th>
+ <label for="login_pass">Login Password</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true ) {
+ %>
+ <input type="text" id="login_pass" value="<%
+ if ( null != vs )
+ out.println(vs.passwd); %>" name="login_pass" maxlength=\"32\" />
+ <%
+ }
+ else{
+ %>
+ <input class="read" readonly type="text" id="login_pass" value="<%
+ if ( null != vs )
+ out.println(vs.passwd); %>" name="login_pass" maxlength=\"32\" />
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("login_pass");
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 32 one-byte characters in English<br>Be effctive only if CheckService : FTP, POP, IMAP, MySQL, PostgreSQL, SIP</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="db">Database Name</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true ) {
+ %>
+ <input type="text" id="db" value="<%
+ if ( null != vs )
+ out.println(vs.passwd); %>" name="db" maxlength=\"32\" />
+ <%
+ }
+ else{
+ %>
+ <input class="read" readonly type="text" id="db" value="<%
+ if ( null != vs )
+ out.println(vs.passwd); %>" name="db" maxlength=\"32\" />
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("db");
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 32 one-byte characters in English<br>Be effctive only if CheckService : MySQL, PostgreSQL</p>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+
+ <h2> RealServer Info</h2>
+ <%
+ if ( (vs != null) && (vs.real != null) && (vs.real.size() != 0 )) {
+ %>
+ <fieldset class="">
+ <legend>Real Servers</legend>
+ <%
+ for (int i = 0; i < vs.real.size(); i++) {
+ int ripNum = i + 1;
+ EndPoint rip = (EndPoint) vs.real.elementAt(i);
+ %>
+ <table class="status">
+ <tr>
+ <td rowspan="3" class="check">
+ <input type="checkbox" name="rs<%= ripNum %>_remove" />
+ </td>
+ <th class="check">
+ <label for="rs<%= ripNum %>_ip">IP Address</label>
+ </th>
+ <td>
+ <input type="text" id="rs<%= ripNum %>_ip" value="<%= rip.host %>" name="rs<%= ripNum %>_ip" maxlength="15" />
+ <%
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("rs" + ripNum + "_ip");
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">[0-255].[0-255].[0-255].[0-255]</p>
+ </td>
+ </tr>
+ <tr>
+ <th class="check">
+ <label for="rs<%= ripNum %>_port">Port Number</label>
+ </th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("rs" + ripNum + "_port");
+ }
+ if (null == rip.port){
+ out.print("<input type=\"text\" id=\"rs\" + ripNum + \"_port\" value=\"\" name=\"rs" + ripNum + "_port\" />");
+ }
+ else {
+ out.print("<input type=\"text\" id=\"rs\" + ripNum + \"_port\" value=\"" + rip.port + "\" name=\"rs" + ripNum + "_port\" />");
+ }
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">1-65535, service name</p>
+ </td>
+ </tr>
+ <tr>
+ <th class="check">
+ <label for="rs<%= ripNum %>_weight">Weight</label>
+ </th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("rs" + ripNum + "_weight");
+ }
+ if ( ( null != invalidMessage ) && ( 1 == rip.weight ) ){
+ out.print("<input type=\"text\" id=\"rs\"" + ripNum + "\"_weight\" value=\"\" name=\"rs" + ripNum + "_weight\" maxlength=\"3\" />");
+ }
+ else {
+ out.print("<input type=\"text\" id=\"rs\"" + ripNum + "\"_weight\" value=\"" + rip.weight + "\" name=\"rs" + ripNum + "_weight\" maxlength=\"3\" />");
+ }
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">0-100<br>Default:1</p>
+ </td>
+ </tr>
+ </table>
+ <%
+ }
+ %>
+ <input name="<%= ButtonMode.REMOVE %>" type="submit" value=" >> Remove RealServers" />
+ </fieldset>
+ <%
+ }
+ %>
+
+
+ <fieldset class="">
+ <legend>New Real Server</legend>
+ <table class="status">
+ <tr>
+ <th>
+ <label for="new_ip">IP Address</label>
+ </th>
+ <td>
+ <input type="text" id="new_ip" value="" name="new_ip" maxlength="15" />
+ </td>
+ <td>
+ <p class="required">[0-255].[0-255].[0-255].[0-255]</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="new_port">Port Number</label>
+ </th>
+ <td>
+ <input type="text" id="new_port" value="" name="new_port" />
+ </td>
+ <td>
+ <p class="required">1-65535, service name</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="new_weight">Weight</label>
+ </th>
+ <td>
+ <input type="text" id="new_weight" value="" name="new_weight" maxlength="3" />
+ </td>
+ <td>
+ <p class="required">0-100</p>
+ </td>
+ </tr>
+ </table>
+ <input name="<%= ButtonMode.ADD %>" type="submit" value=" >> Add a RealServer" />
+ </fieldset>
+
+ <h2> SorryServer Info</h2>
+ <fieldset class="">
+ <legend>Sorry Settings</legend>
+ <table class="status">
+ <tr>
+ <th>
+ <label for="sorry_ip">IP Address</label>
+ </th>
+ <td>
+ <input type="text" id="sorry_ip" value="<%
+ if ( null != vs )
+ out.println(vs.sorryserver.host); %>" name="sorry_ip" maxlength="15" />
+ <%
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("sorry_ip");
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">[0-255].[0-255].[0-255].[0-255]</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="sorry_port">Port Number</label>
+ </th>
+ <td>
+
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("sorry_port");
+ }
+
+ if ( (vs == null) || (null == vs.sorryserver.port) ){
+
+ out.println("<input type=\"text\" id=\"sorry_port\" value=\"\" name=\"sorry_port\" />");
+ }
+ else{
+ out.println("<input type=\"text\" id=\"sorry_port\" value=\"" + vs.sorryserver.port + "\"name=\"sorry_port\" />");
+ }
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">1-65535, service name</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="sorry">Sorry Flag</label>
+ </th>
+ <td>
+ <select id="sorry" name="sorry_flag">
+ <option value=""></option>
+ <option value="on"<%
+ if ( (vs != null ) && (vs.sorryflag) )
+ out.print(" selected");
+ %>>On</option>
+ <option value="off"<%
+ if ( (vs != null ) && !(vs.sorryflag) )
+ out.print(" selected");
+ %>>Off</option>
+ </select>
+ <%
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("sorry_flag");
+ if( null != invalidMessage ){
+ out.println("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Default : Off</p>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+
+ <input type="submit" name="button" value="<%=ButtonMode.APPLY %>" onClick="return confirm(add_vs_apply)" />
+ <%
+ if (dd.autoreload == true) {
+ %>
+ <input type="submit" name="button" value="<%= ButtonMode.SAVE %>" onClick="return confirm(add_vs_save)" />
+ <%
+ if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) {
+ %>
+ <input type="submit" name="button" value="<%= ButtonMode.SAVESYNC %>" onClick="return confirm(add_vs_savesync)" />
+ <%
+ }
+ }
+ %>
+ </form>
+ </div>
+<%
+}
+else{
+ response.sendRedirect(RedirectPages.TOPMENU);
+ return;
+}
+%>
+
+
+ </body>
+</html>
\ No newline at end of file
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41439,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get thread status
+ */
+ String threadStatus = (String) session
+ .getAttribute(SessionKeys.THREAD_STATUS);
+ if (threadStatus == null) {
+ MessageView error = new MessageView(41440,
+ LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) {
+ // nothing to do
+ } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) {
+ response.sendRedirect(RedirectPages.STATE_INFO);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) {
+ response.sendRedirect(RedirectPages.VS_ADD_NG);
+ return;
+ } else {
+ MessageView error = new MessageView(41441,
+ LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.REFRESH_TIME %>" />
+
+ <link rel="stylesheet" type="text/css" href="l7gui_basic_style.css" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Running : Add VirtualService</title>
+</head>
+
+<body>
+
+<h1 class="title">Running : Add VirtualService</h1>
+<h2>Please wait.</h2>
+
+</body>
+</html>
+
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41442,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get VS name
+ */
+ String vsname = (String) session.getAttribute(SessionKeys.VS_NAME);
+ if (vsname == null) {
+ MessageView error = new MessageView(41443,
+ LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.COMMAND_MESSAGE);
+
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41444,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Failed : Add VirtualService</title>
+</head>
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false" />
+
+<div id="content">
+<h1 class="title">Failed : Add VirtualService</h1>
+
+<h2>Add Virtual Service :<%=vsname%></h2>
+<% if ( (message != null) && (errorMessage != null ) ) %>
+<h2>Error Reason :</h2>
+<p class="error">[<%=category%>-<%=errorNumber%>]</p>
+<p class="error"><%=errorMessage%></p>
+
+</div>
+</body>
+</html>
+
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*, java.util.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%
+
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41445, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+ /*
+ * get validation error message
+ */
+ HashMap<String,String> errMessage = (HashMap<String,String>) session.getAttribute(SessionKeys.INVALID_MESSAGE);
+ session.setAttribute(SessionKeys.INVALID_MESSAGE,null);
+
+
+ L7guiFramework framework = new L7guiFramework();
+
+ /*
+ * get cluster status
+ */
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41446, LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ if ( (cd.self_status != ClusterStatus.ACTIVE) && (cd.self_status != ClusterStatus.SINGLE) ){
+ response.sendRedirect(RedirectPages.TOPMENU);
+ return;
+ }
+
+ /*
+ * get l7directrod.cf data
+ */
+ DirectorData dd = framework.getDirectorData();
+ if (dd == null) {
+ MessageView error = new MessageView(41447, LogCategorySet.GUI_IO_FILE,
+ Message.DIRECTOR_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get previous input value
+ */
+ VirtualSetting vs = (VirtualSetting) session.getAttribute(SessionKeys.INPUT_VS);
+ if (vs != null) {
+ session.setAttribute(SessionKeys.INPUT_VS, null);
+ }
+ else {
+ /*
+ * get post data
+ */
+ String post = request.getParameter("vs"); // ex. "10.10.10.10:80:cinsert:--cookie-name monkey"
+ if (post == null) {
+ MessageView error = new MessageView(21101, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.VS_SELECT_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.STATE_INFO);
+ return;
+ }
+
+ String params[] = post.split(":", 4);
+ if (params == null || params.length != 4) {
+ MessageView error = new MessageView(41448, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get l7vsadm data from L7guiFramework
+ */
+ L7vsAdmData admDataList = framework.getAdmData();
+ if (admDataList == null) {
+ MessageView error = new MessageView(41449, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ /*
+ * compare add l7vsadm data with post data
+ */
+ for (int i = 0; i < admDataList.virtualSettings.size(); i++) {
+ VirtualSetting v = (VirtualSetting) admDataList.virtualSettings.elementAt(i);
+ if (v.virtual.host.equals(params[0]) && v.virtual.port.equals(params[1]) &&
+ v.protomod.equals(params[2]) && v.option.equals(params[3])) {
+ vs = v;
+ break;
+ }
+ }
+
+ for (VirtualSetting directordVs : dd.virtualSettings) {
+ if (directordVs.isSameService(vs)) {
+ vs = directordVs;
+ }
+ }
+
+ /*
+ * error. no such VirtualService
+ */
+ if (vs == null) {
+ MessageView error = new MessageView(41450, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+ }
+
+ /*
+ * backup input data
+ */
+ VirtualSetting oldVs = new VirtualSetting(vs);
+ session.setAttribute(SessionKeys.OLD_VS, oldVs);
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if ( cd.self_status == ClusterStatus.ACTIVE ){
+ cssSeat = "l7gui_act_style.css";
+ }
+ else if ( cd.self_status == ClusterStatus.STANDBY ){
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <script src="l7gui.js" type="text/javascript"></script>
+ <noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+
+ <title>Modify VirtualService</title>
+ </head>
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false"/>
+
+
+<div id="content">
+<h1 class="title">Modify VirtualService (<%= vs.virtual.host %>:<%= vs.virtual.port %> <%= vs.protomod %> <%= vs.option %>)</h1>
+
+<%
+ if ( (message != null) && (errorMessage != null)) {
+%>
+ <p class="error">[ <%=category %> - <%=errorNumber %>]</p>
+ <p class="error"> <%=errorMessage %></p>
+<%
+ }
+%>
+
+<form method="post" action="VSModServlet">
+ <h2 class="title">VirtualService Info</h2>
+
+ <fieldset class="">
+ <legend>Basic Settings</legend>
+
+ <table class="status">
+ <tr>
+ <th>
+ <label for="ip">Virtual IP address</label>
+ </th>
+ <td>
+ <input type="text" id="ip" name="vip" value="<%= vs.virtual.host %>" maxlength="15" />
+ <%
+ if ( null != errMessage ){
+ String invalidMessage = errMessage.get("vip");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="item">Required Field</p>
+ <p class="required">[0-255].[0-255].[0-255].[0-255]</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="port">Port Number</label>
+ </th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("port");
+ }
+ if ( null == vs.virtual.port ){
+ out.print("<input type=\"text\" id=\"port\" value=\"\" name=\"port\" />");
+ }
+ else {
+ out.print("<input type=\"text\" id=\"port\" value=\"" + vs.virtual.port + "\"name=\"port\" />");
+ }
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="item">Required Field</p>
+ <p class="required">1-65535</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="protomod">Persistence Type</label>
+ </th>
+ <td>
+ <select id="protomod" name="protomod">
+ <option value="cinsert"<%
+ if (vs.protomod.equals("cinsert"))
+ out.print(" selected");
+ %>>Cookie Insert</option>
+ <option value="url"<%
+ if (vs.protomod.equals("url"))
+ out.print(" selected");
+ %>>URL Pattern</option>
+ <option value="sslid"<%
+ if (vs.protomod.equals("sslid"))
+ out.print(" selected");
+ %>>SSL Session ID</option>
+ <option value="sessionless"<%
+ if (vs.protomod.equals("sessionless"))
+ out.print(" selected");
+ %>>Sessionless</option>
+ </select>
+ <%
+ if ( null != errMessage ){
+ String invalidMessage = errMessage.get("protomod");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="item">Required Field</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="option">Persistence option</label>
+ </th>
+ <td>
+ <input type="text" id="option" name="option" value="<%= vs.option %>" maxlength="127" />
+ <%
+ if ( null != errMessage ){
+ String invalidMessage = errMessage.get("option");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 127 one-byte characters in English</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="sched">Scheduler Type</label>
+ </th>
+ <td>
+ <select id="sched" name="sched">
+ <option value="rr"<%
+ if (vs.sched.equals("rr"))
+ out.print(" selected");
+ %>>Round Robin</option>
+ <option value="wrr"<%
+ if (vs.sched.equals("wrr"))
+ out.print(" selected");
+ %>>Weighted Round Robin</option>
+ <option value="lc"<%
+ if (vs.sched.equals("lc"))
+ out.print(" selected");
+ %>>Least Connection</option>
+ </select>
+ <%
+ if ( null != errMessage ){
+ String invalidMessage = errMessage.get("sched");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required"></p>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+ <fieldset class="">
+ <legend>Advanced Settings</legend>
+ <table class="status">
+ <tr>
+ <th>
+ <label for="qos_srv">QoS (per Virtual Service)</label>
+ </th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ int unit_s = 0;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("qos_service");
+ }
+ if ( ( null != invalidMessage ) && ( 0 == vs.qosservice ) ){
+ out.print("<input type=\"text\" id=\"qos_srv\" value=\"\" name=\"qos_service\" size=\"3\" maxlength=\"3\" />");
+ }
+ else {
+ if ( invalidMessage == null ){
+ while (vs.qosservice >= 1000) {
+ vs.qosservice /= 1000;
+ unit_s++;
+ }
+ }
+ out.print("<input type=\"text\" id=\"qos_srv\" value=\"" + vs.qosservice + "\"name=\"qos_service\" size=\"3\" maxlength=\"3\" />");
+ }
+ %>
+ <select id="qos_srv" name="qos_service_unit">
+ <option value="bps"<%
+ if (unit_s == 0)
+ out.print(" selected");
+ %>>bps</option>
+ <option value="Kbps"<%
+ if (unit_s == 1)
+ out.print(" selected");
+ %>>Kbps</option>
+ <option value="Mbps"<%
+ if (unit_s == 2)
+ out.print(" selected");
+ %>>Mbps</option>
+ <option value="Gbps"<%
+ if (unit_s == 3)
+ out.print(" selected");
+ %>>Gbps</option>
+ </select>
+ <%
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">0-999(bps/Kbps/Mbps/Gbps)</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="qos_conn">QoS (per Client)</label>
+ </th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ int unit_c = 0;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("qos_conn");
+ }
+ if ( ( null != invalidMessage ) && ( 0 == vs.qosclient ) ){
+ out.print("<input type=\"text\" id=\"qos_conn\" value=\"\" name=\"qos_conn\" size=\"3\" maxlength=\"3\" />");
+ }
+ else {
+ if ( null == invalidMessage ){
+ while (vs.qosclient >= 1000) {
+ vs.qosclient /= 1000;
+ unit_c++;
+ }
+ }
+ out.print("<input type=\"text\" id=\"qos_conn\" value=\"" + vs.qosclient + "\" name=\"qos_conn\" size=\"3\" maxlength=\"3\" />");
+ }
+ %>
+ <select id="qos_conn" name="qos_conn_unit">
+ <option value="bps"<%
+ if (unit_c == 0)
+ out.print(" selected");
+ %>>bps</option>
+ <option value="Kbps"<%
+ if (unit_c == 1)
+ out.print(" selected");
+ %>>Kbps</option>
+ <option value="Mbps"<%
+ if (unit_c == 2)
+ out.print(" selected");
+ %>>Mbps</option>
+ <option value="Gbps"<%
+ if (unit_c == 3)
+ out.print(" selected");
+ %>>Gbps</option>
+ </select>
+ <%
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">0-999(bps/Kbps/Mbps/Gbps)</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="max_conn">Max Connections</label>
+ </th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("max_conn");
+ }
+ if ( ( null != invalidMessage ) && ( 0 == vs.maxconn ) ){
+ out.print("<input type=\"text\" id=\"max_conn\" value=\"\" name=\"max_conn\" maxlength=\"6\" />");
+ }
+ else {
+ out.print("<input type=\"text\" id=\"max_conn\" value=\"" + vs.maxconn + "\" name=\"max_conn\" maxlength=\"6\" />");
+ }
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">0-100000<br>Note : "0" means "Unlimited"</p>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+ <fieldset class="">
+ <legend>Monitor Settings</legend>
+ <p class="caution"> <img src="images/exclamation3.gif" alt="Caution!!" width="16" height="14" align="middle">
+ Disable Area when you push "apply" button.</p>
+ <table class="status">
+ <tr>
+ <th>
+ <label for="timeout">Check Timeout</label>
+ </th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("timeout");
+ }
+ if ( ( vs == null ) || ( 0 == vs.timeout ) ){
+ if ( dd.autoreload == true )
+ out.print("<input type=\"text\" id=\"timeout\" value=\"\" name=\"timeout\" maxlength=\"10\" />");
+ else
+ out.print("<input class=\"read\" readonly type=\"text\" id=\"timeout\" value=\"\" name=\"timeout\" maxlength=\"10\" />");
+ }
+ else {
+ if ( dd.autoreload == true )
+ out.print("<input type=\"text\" id=\"timeout\" value=\"" + vs.timeout + "\" name=\"timeout\" maxlength=\"10\" />");
+ else
+ out.print("<input class=\"read\" readonly type=\"text\" id=\"timeout\" value=\"" + vs.timeout + "\" name=\"timeout\" maxlength=\"10\" />");
+
+ }
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">1-2147483647(sec)</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="check_type">Check Type</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true )
+ {
+ %>
+ <input type="text" id="check_type" value="<%= vs.checktype %>" name="check_type" maxlength="9"/>
+ <%
+ }
+ else
+ {
+ %>
+ <input class="read" readonly type="text" id="check_type" value="<%= vs.checktype %>" name="check_type" maxlength="9"/>
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("check_type");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Any Of The Following<br>negotiate, connect, ping, off, on, 0-9</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="check_service">Check Service</label>
+ </th>
+ <td>
+ <% if (dd.autoreload ==true ){
+ %>
+ <select id="check_service" name="check_service">
+ <option value=""<%
+ if (vs.service.equals(""))
+ out.print(" selected");
+ %>></option>
+ <option value="ftp"<%
+ if (vs.service.equals("ftp"))
+ out.print(" selected");
+ %>>FTP</option>
+ <option value="smtp"<%
+ if (vs.service.equals("smtp"))
+ out.print(" selected");
+ %>>SMTP</option>
+ <option value="dns"<%
+ if (vs.service.equals("dns"))
+ out.print(" selected");
+ %>>DNS</option>
+ <option value="http"<%
+ if (vs.service.equals("http"))
+ out.print(" selected");
+ %>>HTTP</option>
+ <option value="pop"<%
+ if (vs.service.equals("pop"))
+ out.print(" selected");
+ %>>POP</option>
+ <option value="nntp"<%
+ if (vs.service.equals("nntp"))
+ out.print(" selected");
+ %>>NNTP</option>
+ <option value="imap"<%
+ if (vs.service.equals("imap"))
+ out.print(" selected");
+ %>>IMAP</option>
+ <option value="ldap"<%
+ if (vs.service.equals("ldap"))
+ out.print(" selected");
+ %>>LDAP</option>
+ <option value="https"<%
+ if (vs.service.equals("https"))
+ out.print(" selected");
+ %>>HTTPS</option>
+ <option value="mysql"<%
+ if (vs.service.equals("mysql"))
+ out.print(" selected");
+ %>>MySQL</option>
+ <option value="pgsql"<%
+ if (vs.service.equals("pgsql"))
+ out.print(" selected");
+ %>>PostgreSQL</option>
+ <option value="sip"<%
+ if (vs.service.equals("sip"))
+ out.print(" selected");
+ %>>SIP</option>
+ <option value="none"<%
+ if (vs.service.equals("none"))
+ out.print(" selected");
+ %>>None</option>
+ </select>
+ <%
+ }
+ else
+ {
+ %>
+ <select class="read" disabled id="check_service" name="check_service">
+ <option value=""<%
+ if (vs.service.equals(""))
+ out.print(" selected");
+ %>></option>
+ <option value="ftp"<%
+ if (vs.service.equals("ftp"))
+ out.print(" selected");
+ %>>FTP</option>
+ <option value="smtp"<%
+ if (vs.service.equals("smtp"))
+ out.print(" selected");
+ %>>SMTP</option>
+ <option value="dns"<%
+ if (vs.service.equals("dns"))
+ out.print(" selected");
+ %>>DNS</option>
+ <option value="http"<%
+ if (vs.service.equals("http"))
+ out.print(" selected");
+ %>>HTTP</option>
+ <option value="pop"<%
+ if (vs.service.equals("pop"))
+ out.print(" selected");
+ %>>POP</option>
+ <option value="nntp"<%
+ if (vs.service.equals("nntp"))
+ out.print(" selected");
+ %>>NNTP</option>
+ <option value="imap"<%
+ if (vs.service.equals("imap"))
+ out.print(" selected");
+ %>>IMAP</option>
+ <option value="ldap"<%
+ if (vs.service.equals("ldap"))
+ out.print(" selected");
+ %>>LDAP</option>
+ <option value="https"<%
+ if (vs.service.equals("https"))
+ out.print(" selected");
+ %>>HTTPS</option>
+ <option value="mysql"<%
+ if (vs.service.equals("mysql"))
+ out.print(" selected");
+ %>>MySQL</option>
+ <option value="pgsql"<%
+ if (vs.service.equals("pgsql"))
+ out.print(" selected");
+ %>>PostgreSQL</option>
+ <option value="sip"<%
+ if (vs.service.equals("sip"))
+ out.print(" selected");
+ %>>SIP</option>
+ <option value="none"<%
+ if (vs.service.equals("none"))
+ out.print(" selected");
+ %>>None</option>
+ </select>
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("check_service");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required"></p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="quiescent">Quiescent</label>
+ </th>
+ <td>
+ <%if (dd.autoreload== true) {
+ %>
+ <select id="quiescent" name="quiescent">
+ <option value=""<%
+ if (vs.quiescent.equals("") )
+ out.print(" selected");
+ %>></option>
+ <option value="yes"<%
+ if (vs.quiescent.equals("yes") )
+ out.print(" selected");
+ %>>Yes</option>
+ <option value="no"<%
+ if (vs.quiescent.equals("no") )
+ out.print(" selected");
+ %>>No</option>
+ </select>
+ <%
+ }
+ else
+ {
+ %>
+ <select class="read" disabled id="quiescent" name="quiescent">
+ <option value=""<%
+ if (vs.quiescent.equals("") )
+ out.print(" selected");
+ %>></option>
+ <option value="yes"<%
+ if (vs.quiescent.equals("yes") )
+ out.print(" selected");
+ %>>Yes</option>
+ <option value="no"<%
+ if (vs.quiescent.equals("no") )
+ out.print(" selected");
+ %>>No</option>
+ </select>
+
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("quiescent");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Default : No</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="down_callback">Real Server Down Callback</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true )
+ {
+ %>
+ <input type="text" id="down_callback" value="<%= vs.downcallback %>" name="down_callback" maxlength=\"127\" />
+ <%
+ }
+ else
+ {
+ %>
+ <input class="read" readonly type="text" id="down_callback" value="<%= vs.downcallback %>" name="down_callback" maxlength=\"127\" />
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("down_callback");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 127 one-byte characters in English<br>Be effctive only if CheckService : HTTP, HTTPS, LDAP, MySQL, PostgreSQL, SIP, None</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="up_callback">Real Server Up Callback</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true )
+ {
+ %>
+ <input type="text" id="up_callback" value="<%= vs.upcallback %>" name="up_callback" maxlength=\"127\" />
+ <%
+ }
+ else
+ {
+ %>
+ <input class="read" readonly type="text" id="up_callback" value="<%= vs.upcallback %>" name="up_callback" maxlength=\"127\" />
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("up_callback");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 127 one-byte characters in English</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="check_port">Check Port</label>
+ </th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("check_port");
+ }
+ if ( ( vs == null ) || ( 0 == vs.checkport ) ){
+ if (dd.autoreload == true)
+ out.print("<input type=\"text\" id=\"check_port\" value=\"\" name=\"check_port\" maxlength=\"5\" />");
+ else
+ out.print("<input class=\"read\" readonly type=\"text\" id=\"check_port\" value=\"\" name=\"check_port\" maxlength=\"5\" />");
+ }
+ else {
+ if (dd.autoreload == true)
+ out.print("<input type=\"text\" id=\"check_port\" value=\"" + vs.checkport + "\" name=\"check_port\" maxlength=\"5\" />");
+ else
+ out.print("<input class=\"read\" readonly type=\"text\" id=\"check_port\" value=\"" + vs.checkport + "\" name=\"check_port\" maxlength=\"5\" />");
+ }
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">1-65535</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="request">Request Path</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true )
+ {
+ %>
+ <input type="text" id="request" value="<%= vs.request %>" name="request" maxlength=\"127\" />
+ <%
+ }
+ else
+ {
+ %>
+ <input class="read" readonly type="text" id="request" value="<%= vs.request %>" name="request" maxlength=\"127\" />
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("request");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to one-byte characters in English<br>Be effctive only if CheckService : HTTP, HTTPS, LDAP, MySQL, PostgreSQL, SIP, None</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="receive">Receive String</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true )
+ {
+ %>
+ <input type="text" id="receive" value="<%= vs.receive %>" name="receive" maxlength=\"127\" />
+ <%
+ }
+ else
+ {
+ %>
+ <input class="read" readonly type="text" id="receive" value="<%= vs.receive %>" name="receive" maxlength=\"127\" />
+
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("receive");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 127 one-byte characters in English<br>Be effctive only if CheckService : HTTP, HTTPS, LDAP, FTP, DNS</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="method">HTTP Method</label>
+ </th>
+ <td>
+ <% if (dd.autoreload ==true ){
+ %>
+ <select id="method" name="method">
+ <option value=""<%
+ if (vs.httpmethod.equals(""))
+ out.print(" selected");
+ %>></option>
+ <option value="GET"<%
+ if (vs.httpmethod.equals("GET"))
+ out.print(" selected");
+ %>>GET</option>
+ <option value="HEAD"<%
+ if (vs.httpmethod.equals("HEAD"))
+ out.print(" selected");
+ %>>HEAD</option>
+ </select>
+ <%
+ }
+ else
+ {
+ %>
+ <select class="read" disabled id="method" name="method">
+ <option value=""<%
+ if (vs.httpmethod.equals(""))
+ out.print(" selected");
+ %>></option>
+ <option value="GET"<%
+ if (vs.httpmethod.equals("GET"))
+ out.print(" selected");
+ %>>GET</option>
+ <option value="HEAD"<%
+ if (vs.httpmethod.equals("HEAD"))
+ out.print(" selected");
+ %>>HEAD</option>
+ </select>
+
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("method");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Be effctive only if CheckService : HTTP, HTTPS</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="virtual_host">Virtual Host</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true )
+ {
+ %>
+ <input type="text" id="virtual_host" value="<%= vs.virtualhost %>" name="virtual_host" maxlength=\"127\" />
+ <%
+ }
+ else
+ {
+ %>
+ <input class="read" readonly type="text" id="virtual_host" value="<%= vs.virtualhost %>" name="virtual_host" maxlength=\"127\" />
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("virtual_host");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 127 one-byte characters in English<br>Be effctive only if CheckService : HTTP, HTTPS</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="login_user">Login Username</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true )
+ {
+ %>
+ <input type="text" id="login_user" value="<%= vs.login %>" name="login_user" maxlength=\"32\" />
+ <%
+ }
+ else
+ {
+ %>
+ <input class="read" readonly type="text" id="login_user" value="<%= vs.login %>" name="login_user" maxlength=\"32\" />
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("login_user");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 32 one-byte characters in English<br>Followings : Effctive only when CheckService is FTP, POP, IMAP, MySQL, PostgreSQL, and SIP</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="login_pass">Login Password</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true )
+ {
+ %>
+ <input type="text" id="login_pass" value="<%= vs.passwd %>" name="login_pass" maxlength=\"32\" />
+ <%
+ }
+ else
+ {
+ %>
+ <input class="read" readonly type="text" id="login_pass" value="<%= vs.passwd %>" name="login_pass" maxlength=\"32\" />
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("login_pass");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 32 one-byte characters in English<br>Be effctive only if CheckService : FTP, POP, IMAP, MySQL, PostgreSQL, SIP</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="db">Database Name</label>
+ </th>
+ <td>
+ <%
+ if ( dd.autoreload == true )
+ {
+ %>
+ <input type="text" id="db" value="<%= vs.database %>" name="db" maxlength=\"32\" />
+ <%
+ }
+ else
+ {
+ %>
+ <input class="read" readonly type="text" id="db" value="<%= vs.database %>" name="db" maxlength=\"32\" />
+ <%
+ }
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("db");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Up to 32 one-byte characters in English<br>Be effctive only if CheckService : MySQL, PostgreSQL</p>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+
+ <h2> RealServer Info</h2>
+ <%
+ if ( (vs.real != null) && (vs.real.size() != 0)) {
+ %>
+ <fieldset class="">
+ <legend>Real Servers</legend>
+ <%
+ for (int i = 0; i < vs.real.size(); i++) {
+ int ripNum = i + 1;
+ EndPoint rip = (EndPoint) vs.real.elementAt(i);
+ %>
+ <table class="status">
+ <tr>
+ <td rowspan="3" class="check">
+ <input type="checkbox" name="rs<%= ripNum %>_remove" />
+ </td>
+ <th class="check">
+ <label for="rs<%= ripNum %>_ip">IP Address</label>
+ </th>
+ <td>
+ <input type="text" id="rs<%= ripNum %>_ip" value="<%= rip.host %>" name="rs<%= ripNum %>_ip" maxlength="15" />
+ <%
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("rs" + ripNum + "_ip");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">[0-255].[0-255].[0-255].[0-255]</p>
+ </td>
+ </tr>
+ <tr>
+ <th class="check">
+ <label for="rs<%= ripNum %>_port">Port Number</label>
+ </th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("rs" + ripNum + "_port");
+ }
+ if ( null == rip.port ){
+ out.print("<input type=\"text\" id=\"rs\" + ripNum + \"_port\" value=\"\" name=\"rs" + ripNum + "_port\" />");
+ }
+ else {
+ out.print("<input type=\"text\" id=\"rs\" + ripNum + \"_port\" value=\"" + rip.port + "\" name=\"rs" + ripNum + "_port\" />");
+ }
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">1-65535</p>
+ </td>
+ </tr>
+ <tr>
+ <th class="check">
+ <label for="rs<%= ripNum %>_weight">Weight</label>
+ </th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("rs" + ripNum + "_weight");
+ }
+ if ( ( null != invalidMessage ) && ( 1 == rip.weight ) ){
+ out.print("<input type=\"text\" id=\"rs" + ripNum + "_weight\" value=\"\" name=\"rs" + ripNum + "_weight\" maxlength=\"3\" />");
+ }
+ else {
+ out.print("<input type=\"text\" id=\"rs" + ripNum + "_weight\" value=\"" + rip.weight + "\" name=\"rs" + ripNum + "_weight\" maxlength=\"3\" />");
+ }
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">0-100<br>Default:1</p>
+ </td>
+ </tr>
+ </table>
+ <%
+ }
+ %>
+ <input name="<%= ButtonMode.REMOVE %>" type="submit" value=" >> Remove RealServers" />
+ </fieldset>
+ <%
+ }
+ %>
+
+ <fieldset class="">
+ <legend>New Real Server</legend>
+ <table class="status">
+ <tr>
+ <th>
+ <label for="new_ip">IP Address</label>
+ </th>
+ <td>
+ <input type="text" id="new_ip" value="" name="new_ip" maxlength="15" />
+ </td>
+ <td>
+ <p class="required">[0-255].[0-255].[0-255].[0-255]</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="new_port">Port Number</label>
+ </th>
+ <td>
+ <input type="text" id="new_port" value="" name="new_port" />
+ </td>
+ <td>
+ <p class="required">1-65535</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="new_weight">Weight</label>
+ </th>
+ <td>
+ <input type="text" id="new_weight" value="" name="new_weight" maxlength="3" />
+ </td>
+ <td>
+ <p class="required">0-100</p>
+ </td>
+ </tr>
+ </table>
+ <input name="<%= ButtonMode.ADD %>" type="submit" value=" >> Add a RealServer" />
+ </fieldset>
+
+ <h2> SorryServer Info</h2>
+ <fieldset class="">
+ <legend>Sorry Settings</legend>
+ <table class="status">
+ <tr>
+ <th>
+ <label for="sorry_ip">IP Address</label>
+ </th>
+ <td>
+ <input type="text" id="sorry_ip" value="<%= vs.sorryserver.host %>" name="sorry_ip" maxlength="15" />
+ <%
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("sorry_ip");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">[0-255].[0-255].[0-255].[0-255]</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="sorry_port">Port Number</label>
+ </th>
+ <td>
+ <%
+ {
+ String invalidMessage = null;
+ if ( null != errMessage ) {
+ invalidMessage = errMessage.get("sorry_port");
+ }
+ if ( null == vs.sorryserver.port ) {
+ out.print("<input type=\"text\" id=\"sorry_port\" value=\"\" name=\"sorry_port\" />");
+ }
+ else {
+ out.print("<input type=\"text\" id=\"sorry_port\" value=\"" + vs.sorryserver.port + "\"name=\"sorry_port\" />");
+ }
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">1-65535</p>
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <label for="sorry">Sorry Flag</label>
+ </th>
+ <td>
+ <select id="sorry" name="sorry_flag">
+ <option value="on"<%
+ if (vs.sorryflag)
+ out.print(" selected");
+ %>>On</option>
+ <option value="off"<%
+ if (!vs.sorryflag)
+ out.print(" selected");
+ %>>Off</option>
+ </select>
+ <%
+ if ( null != errMessage ) {
+ String invalidMessage = errMessage.get("sorry_flag");
+ if( null != invalidMessage ){
+ out.print("<p class=\"invalid\">" + invalidMessage + "</p>");
+ }
+ }
+ %>
+ </td>
+ <td>
+ <p class="required">Default : Off</p>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+ <input type="submit" name="button" value="<%= ButtonMode.APPLY %>" onClick="return confirm(modify_vs_apply)" />
+ <%
+ if (dd.autoreload == true) {
+ %>
+ <input type="submit" name="button" value="<%=ButtonMode.SAVE %>" onClick="return confirm(modify_vs_save)" />
+ <%
+ if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) {
+ %>
+ <input type="submit" name="button" value="<%=ButtonMode.SAVESYNC %>" onClick="return confirm(modify_vs_savesync)" />
+ <%
+ }
+ }
+ %>
+</form>
+
+</div>
+</body>
+</html>
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41451,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get thread status
+ */
+ String threadStatus = (String) session
+ .getAttribute(SessionKeys.THREAD_STATUS);
+ if (threadStatus == null) {
+ MessageView error = new MessageView(41452,
+ LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) {
+ // nothing to do
+ } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) {
+ response.sendRedirect(RedirectPages.STATE_INFO);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) {
+ response.sendRedirect(RedirectPages.VS_MODIFY_NG);
+ return;
+ } else {
+ MessageView error = new MessageView(41453,
+ LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.REFRESH_TIME %>" />
+
+ <link rel="stylesheet" type="text/css" href="l7gui_basic_style.css" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Running : Modify VirtualService</title>
+</head>
+
+<body>
+
+<h1 class="title">Running : Modify VirtualService</h1>
+<h2>Please wait.</h2>
+
+</body>
+</html>
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41454,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get VS name
+ */
+ String vsname = (String) session.getAttribute(SessionKeys.VS_NAME);
+ if (vsname == null) {
+ MessageView error = new MessageView(41455,
+ LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.COMMAND_MESSAGE);
+
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41456,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Failed : Modify VirtualService</title>
+</head>
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false" />
+
+<div id="content">
+<h1 class="title">Failed : Modify VirtualService</h1>
+
+<h2>Modify Virtual Service :<%=vsname%></h2>
+<h2>Error Reason :</h2>
+<p class="error">[<%=category%>-<%=errorNumber%>]</p>
+<p class=error><%=errorMessage%></p>
+
+</div>
+</body>
+</html>
--- /dev/null
+<%@ page import="org.ultramonkey.l7.model.*,
+ org.ultramonkey.l7.controller.*,
+ org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+
+
+<%
+ /*
+ * check session
+ */
+ if (session.isNew()) {
+ MessageView error = new MessageView(41457, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get VS name
+ */
+ String vsname = (String)session.getAttribute(SessionKeys.VS_NAME);
+
+ if(vsname == null){
+ MessageView error = new MessageView(41458, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get result message
+ */
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.COMMAND_MESSAGE);
+
+ if (message != null) {
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41459,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title> Succeeded : Remove VirtualService </title>
+</head>
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false"/>
+
+<div id="content">
+<h1 class="title">Succeeded : Remove VirtualService </h1>
+
+<h2> Remove Virtual Service : <br> <%= vsname %> </h2>
+</div>
+</body>
+</html>
+
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41460,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get thread status
+ */
+ String threadStatus = (String) session
+ .getAttribute(SessionKeys.THREAD_STATUS);
+ if (threadStatus == null) {
+ MessageView error = new MessageView(41461,
+ LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) {
+ // nothing to do
+ } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) {
+ response.sendRedirect(RedirectPages.VS_REMOVE_SUCCESS);
+ return;
+ } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) {
+ response.sendRedirect(RedirectPages.VS_REMOVE_NG);
+ return;
+ } else {
+ MessageView error = new MessageView(41462,
+ LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <meta http-equiv="refresh" content="<%= RedirectPages.REFRESH_TIME %>" />
+
+ <link rel="stylesheet" type="text/css" href="l7gui_basic_style.css" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Running : Remove VirtualService</title>
+</head>
+
+<body>
+
+<h1 class="title">Running : Remove VirtualService</h1>
+<h2>Please wait.</h2>
+
+</body>
+</html>
--- /dev/null
+<%@ page
+ import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*"
+ language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+
+<%
+ /*
+ * check session
+ */
+ L7guiServletBase base = new L7guiServletBase();
+ if (session.isNew() || base.checkSession(session) == false) {
+ MessageView error = new MessageView(41463,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get VS name
+ */
+ String vsname = (String) session.getAttribute(SessionKeys.VS_NAME);
+ if (vsname == null) {
+ MessageView error = new MessageView(41464,
+ LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * get command message & result message
+ */
+ MessageView message = (MessageView) session
+ .getAttribute(SessionKeys.COMMAND_MESSAGE);
+
+ MessageView resultMessage = (MessageView) session
+ .getAttribute(SessionKeys.RESULT_MESSAGE);
+
+ String errorMessage = "";
+ int errorNumber = 0;
+ String category = "";
+
+ if (message != null) {
+ errorMessage = message.getMessage();
+ errorNumber = message.getErrno();
+ category = message.getCategory();
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
+ }
+
+ else if (resultMessage != null) {
+ errorMessage = resultMessage.getMessage();
+ errorNumber = resultMessage.getErrno();
+ category = resultMessage.getCategory();
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
+ }
+
+
+ /*
+ * get cluster status
+ */
+ L7guiFramework framework = new L7guiFramework();
+ ClusterData cd = framework.getClusterData();
+ if (cd == null) {
+ MessageView error = new MessageView(41465,
+ LogCategorySet.GUI_IO_COMMAND,
+ Message.CLUSTER_DATA_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ return;
+ }
+
+ /*
+ * fix style seat
+ */
+ String cssSeat = "l7gui_single_style.css";
+ if (cd.self_status == ClusterStatus.ACTIVE) {
+ cssSeat = "l7gui_act_style.css";
+ } else if (cd.self_status == ClusterStatus.STANDBY) {
+ cssSeat = "l7gui_sby_style.css";
+ }
+%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Cache-Control" content="no-cache">
+ <meta http-equiv="Expires" content="0">
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <noscript>
+ <meta http-equiv="refresh"
+ content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>" />
+ </noscript>
+ <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
+ <link rel="shortcut icon" href="images/favicon.ico" />
+ <title>Failed : Remove VirtualService</title>
+</head>
+
+<body class="normal">
+
+<jsp:include page="menu.jsp" flush="false" />
+
+<div id="content">
+<h1 class="title">Failed : Remove VirtualService</h1>
+
+<h2>Remove Virtual Service :<%=vsname%></h2>
+<% if ( ( (message != null) || (resultMessage != null) ) && (errorMessage != null) ){
+%>
+ <h2>Error Reason :</h2>
+ <p class="error">[<%=category%>-<%=errorNumber%>]</p>
+ <p class="error"><%=errorMessage%></p>
+<% }
+%>
+</div>
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+# root logger
+#log4j.rootLogger=INFO, root
+#log4j.appender.root = org.apache.log4j.ConsoleAppender
+#log4j.appender.root.layout = org.apache.log4j.PatternLayout
+#log4j.appender.root.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} [%-5p] %c %m at %C{1}.java:%L%n
+#log4j.appender.root.threshold = INFO
+
+# l7gui logger
+log4j.category.l7gui_StartStop = INFO, gui
+log4j.category.l7gui_UserAuthentication = INFO, gui
+log4j.category.l7gui_VirtualService = INFO, gui
+log4j.category.l7gui_Monitor = INFO, gui
+log4j.category.l7gui_SnmpAgent = INFO, gui
+log4j.category.l7gui_Replication = INFO, gui
+log4j.category.l7gui_Log = INFO, gui
+log4j.category.l7gui_UserManage = INFO, gui
+log4j.category.l7gui_Redundant = INFO, gui
+log4j.category.l7gui_Save = INFO, gui
+log4j.category.l7gui_Sync = INFO, gui
+log4j.category.l7gui_SaveSync = INFO, gui
+log4j.category.l7gui_I/O = INFO, gui
+log4j.category.l7gui_I/O.File = INFO
+log4j.category.l7gui_I/O.Command = INFO
+log4j.appender.gui = org.apache.log4j.RollingFileAppender
+log4j.appender.gui.File=/var/log/l7vs/l7gui.log
+log4j.appender.gui.Append=true
+log4j.appender.gui.MaxFileSize=10MB
+log4j.appender.gui.MaxBackupIndex=9
+log4j.appender.gui.layout = org.apache.log4j.PatternLayout
+log4j.appender.gui.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} [%-5p] %c %m at %C{1}.java:%L%n
+log4j.appender.gui.threshold = INFO
+
+# l7sync logger
+log4j.category.l7sync_StartStop = INFO, sync
+log4j.category.l7sync_Connection = INFO, sync
+log4j.category.l7sync_Sync = INFO, sync
+log4j.category.l7sync_Sync.DirectorData = INFO
+log4j.category.l7sync_Sync.L7vsdConfData = INFO
+log4j.category.l7sync_Sync.UserData = INFO
+log4j.appender.sync = org.apache.log4j.RollingFileAppender
+log4j.appender.sync.File=/var/log/l7vs/l7sync.log
+log4j.appender.sync.Append=true
+log4j.appender.sync.MaxFileSize=10MB
+log4j.appender.sync.MaxBackupIndex=9
+log4j.appender.sync.layout = org.apache.log4j.PatternLayout
+log4j.appender.sync.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} [%-5p] %c %m at %C{1}.java:%L%n
+log4j.appender.sync.threshold = INFO
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.*;
+import java.util.regex.*;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.LogCategorySet;
+
+/**
+ *
+ * <p>
+ * class ClusterController
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author tanuma
+ */
+public class ClusterController {
+
+ /*
+ * TODO This class is only for Heartbeat cluster now. We have to be
+ * refactoring for any cluster software using JNDI later.
+ */
+
+ private Logger ioCommandLogger = Logger.getLogger(LogCategorySet.GUI_IO_COMMAND);
+
+ protected static ClusterData data = null;
+
+ private static final String CRM_MON = "/usr/sbin/crm_mon";
+
+ private static final String CRM_STANDBY = "/usr/sbin/crm_standby";
+
+ private static final int CHECK_TIMEOUT = 10;
+
+ private static String HB_LOG = "/var/log/ha-log";
+
+ /**
+ *
+ * <p>
+ * getData method
+ * </p>
+ *
+ * @return cluster data
+ */
+ public ClusterData getData() {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11558 ClusterController::getData() in");
+ }
+ // --- debug log (in method) ---
+
+ synchronized (this) {
+ String command = CRM_MON + " -1";
+ String result = runProcess(command);
+
+ ClusterData data = new ClusterData();
+ data.self_status = ClusterStatus.SINGLE;
+ data.logFileName = HB_LOG;
+
+ try {
+ InetAddress local = InetAddress.getLocalHost();
+ String host = local.getHostName();
+ data.self_ip = local.getHostAddress();
+
+ if (result != null) {
+ Pattern p = Pattern.compile("^Node: ([^ ]+)[^:]+: (\\w+)$",
+ Pattern.MULTILINE);
+ Matcher m = p.matcher(result);
+ while (m.find()) {
+ if (host.equals(m.group(1))) {
+ data.self_hostname = m.group(1);
+ data.self_ip = local.getHostAddress();
+ if ("OFFLINE".equals(m.group(2)))
+ data.self_status = ClusterStatus.OUT_OF_SERVICE;
+ else if ("online".equals(m.group(2)))
+ data.self_status = ClusterStatus.STANDBY;
+ else if ("standby".equals(m.group(2)))
+ data.self_status = ClusterStatus.OUT_OF_SERVICE;
+ else
+ data.self_status = ClusterStatus.SINGLE;
+ } else {
+ data.other_hostname = m.group(1);
+ try {
+ data.other_ip = InetAddress.getByName(m.group(1))
+ .getHostAddress();
+ } catch (UnknownHostException e) {
+ ioCommandLogger.info("21100 name resolution failed: " + m.group(1));
+ data.other_ip = null;
+ }
+ if ("OFFLINE".equals(m.group(2)))
+ data.other_status = ClusterStatus.OUT_OF_SERVICE;
+ else if ("online".equals(m.group(2)))
+ data.other_status = ClusterStatus.STANDBY;
+ else if ("standby".equals(m.group(2)))
+ data.other_status = ClusterStatus.OUT_OF_SERVICE;
+ else
+ data.other_status = ClusterStatus.SINGLE;
+ }
+ }
+ p = Pattern.compile("Started ([-\\.\\w]+)$", Pattern.MULTILINE);
+ m = p.matcher(result);
+ while (m.find()) {
+ if (m.group(1).equals(data.self_hostname)
+ && data.self_status == ClusterStatus.STANDBY)
+ data.self_status = ClusterStatus.ACTIVE;
+ else if (m.group(1).equals(data.other_hostname)
+ && data.other_status == ClusterStatus.STANDBY)
+ data.other_status = ClusterStatus.ACTIVE;
+ }
+ }
+ } catch (Exception e) {
+ ioCommandLogger.error("41242 Exception occured: " + e.getMessage());
+ data = null;
+ }
+
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("ClusterController::getData() out ");
+ buf.append("return=(" + data + ")");
+ ioCommandLogger.debug("11559 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+ return data;
+ }
+ }
+
+ /**
+ *
+ * <p>
+ * setData method
+ * </p>
+ *
+ * @param cd
+ */
+ public void setData(ClusterData cd) {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("ClusterController::setData(ClusterData cd) in ");
+ buf.append("cd=(" + cd + ")");
+ ioCommandLogger.debug("11560 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ synchronized (this) {
+ data = cd;
+ }
+
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11561 ClusterController::setData(ClusterData cd) out");
+ }
+ // --- debug log (in method) ---
+ }
+
+ /**
+ *
+ * <p>
+ * changeClusterMode method
+ * </p>
+ *
+ * @return result of switch over.
+ */
+ public boolean changeClusterMode() {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11562 ClusterController::changeClusterMode() in");
+ }
+ // --- debug log (in method) ---
+
+ synchronized (this) {
+ // get current status
+ ClusterData data = this.getData();
+ String command = null;
+ boolean self_flag = true;
+
+ if (data != null && data.self_status == ClusterStatus.ACTIVE
+ && data.other_status == ClusterStatus.STANDBY) {
+ self_flag = true;
+ command = CRM_STANDBY + " -U " + data.self_hostname + " -v on";
+ } else if (data != null && data.other_status == ClusterStatus.ACTIVE
+ && data.self_status == ClusterStatus.STANDBY) {
+ self_flag = false;
+ command = CRM_STANDBY + " -U " + data.other_hostname + " -v on";
+ } else {
+ ioCommandLogger.error("41243 Invalid status: " + data);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11563 ClusterController::changeClusterMode() out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ // run crm_standby command
+ String result = runProcess(command);
+ if (result == null || result.length() != 0) {
+ ioCommandLogger.error("41244 Command error: command=" + command);
+ ioCommandLogger.error("41245 Command error: result=" + result);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11564 ClusterController::changeClusterMode() out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ int timeout = CHECK_TIMEOUT;
+
+ while (true) {
+ // reload current status
+ data = this.getData();
+
+ if (data == null) {
+ ioCommandLogger.error("41246 Invalid status: " + data);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11565 ClusterController::changeClusterMode() out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ } else if (self_flag) {
+ if (data.self_status == ClusterStatus.OUT_OF_SERVICE
+ && data.other_status == ClusterStatus.ACTIVE) {
+ command = CRM_STANDBY + " -U " + data.self_hostname
+ + " -v off";
+ break;
+ }
+ } else {
+ if (data.other_status == ClusterStatus.OUT_OF_SERVICE
+ && data.self_status == ClusterStatus.ACTIVE) {
+ command = CRM_STANDBY + " -U " + data.other_hostname
+ + " -v off";
+ break;
+ }
+ }
+
+ timeout--;
+ if (timeout <= 0) {
+ ioCommandLogger.error("41247 Switch-Over timeout(" + CHECK_TIMEOUT + "sec)");
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11566 ClusterController::changeClusterMode() out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ ioCommandLogger.error("41248 Exception occured: " + e.getMessage());
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11567 ClusterController::changeClusterMode() out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+ }
+
+ // run crm_standby command
+ result = runProcess(command);
+ if (result == null || result.length() != 0) {
+ ioCommandLogger.error("41249 Command error: command=" + command);
+ ioCommandLogger.error("41250 Command error: result=" + result);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11568 ClusterController::changeClusterMode() out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ // reload current status
+ data = this.getData();
+
+ if (data == null) {
+ ioCommandLogger.error("41251 Invalid status: null");
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11569 ClusterController::changeClusterMode() out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ } else if (self_flag) {
+ if (data.self_status != ClusterStatus.STANDBY
+ || data.other_status != ClusterStatus.ACTIVE) {
+ ioCommandLogger.error("41252 Invalid status: " + data);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11570 ClusterController::changeClusterMode() out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+ } else {
+ if (data.other_status != ClusterStatus.STANDBY
+ || data.self_status != ClusterStatus.ACTIVE) {
+ ioCommandLogger.error("41253 Invalid status: " + data);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11571 ClusterController::changeClusterMode() out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+ }
+
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11572 ClusterController::changeClusterMode() out return=true");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+ }
+
+ /**
+ *
+ * <p>
+ * runProcess method
+ * </p>
+ *
+ * @param command
+ * @return result string of command execution
+ */
+ protected String runProcess(String command) {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("ClusterController::runProcess(String command) in ");
+ buf.append("command=\"" + command + "\"");
+ ioCommandLogger.debug("11573 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+ synchronized (this) {
+ StringBuffer result = new StringBuffer();
+
+ try {
+ // TODO using sudo command temporally
+ Process p = Runtime.getRuntime().exec("sudo " + command);
+ InputStream stderr = p.getErrorStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(stderr));
+ String line = null;
+ while ((line = br.readLine()) != null) {
+ result.append(line + "\n");
+ }
+ InputStream is = p.getInputStream();
+ br = new BufferedReader(new InputStreamReader(is));
+ while ((line = br.readLine()) != null) {
+ result.append(line + "\n");
+ }
+ } catch (Exception e) {
+ ioCommandLogger.error("41254 Exception occured: " + e.getMessage());
+ result = null;
+ }
+
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11574 ClusterController::runProcess(String command) out return=" + result);
+ }
+ // --- debug log (out method) ---
+ return (result == null) ? null : result.toString();
+ }
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+import java.io.Serializable;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.LogCategorySet;
+
+/**
+ * <p>class ClusterData</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author nakai
+ */
+public class ClusterData implements Serializable {
+ static final long serialVersionUID = 1;
+
+ /**
+ * cluster status (self node)
+ */
+ public ClusterStatus self_status;
+
+ /**
+ * cluster status (other node)
+ */
+ public ClusterStatus other_status;
+
+ /**
+ * self IP address
+ */
+ public String self_ip;
+
+ /**
+ * self Hostname
+ */
+ public String self_hostname;
+
+ /**
+ * other IP address
+ */
+ public String other_ip;
+
+ /**
+ * other Hostname
+ */
+ public String other_hostname;
+
+ public String logFileName;
+
+ /**
+ *
+ * Constructor
+ *
+ */
+ public ClusterData() {
+ // --- debug log (constructor) ---
+ Logger redundantLogger = Logger.getLogger(LogCategorySet.GUI_REDUNDANT);
+ if (redundantLogger.isDebugEnabled()) {
+ redundantLogger.debug("11557 class ClusterData created.");
+ }
+ // --- debug log (constructor) ---
+
+ this.self_status = ClusterStatus.NONE;
+ this.other_status = ClusterStatus.NONE;
+ this.self_ip = null;
+ this.self_hostname = null;
+ this.other_ip = null;
+ this.other_hostname = null;
+ this.logFileName = null;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public String toString() {
+ return
+ "self_status=" + this.self_status + ", " +
+ "self_ip=\"" + this.self_ip + "\", " +
+ "self_hostname=\"" + this.self_hostname + "\", " +
+ "other_status=" + this.other_status + ", " +
+ "other_ip=\"" + this.other_ip + "\", " +
+ "other_hostname=\"" + this.other_hostname + "\", " +
+ "logFileName=\"" + this.logFileName + "\"";
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+/**
+ * <p>class ControlerStatus</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author nakai
+ */
+public enum ClusterStatus {
+ /**
+ * cluster is active (running cluster process and having resources)
+ */
+ ACTIVE,
+ /**
+ * cluster is standby (running cluster process and having no resources)
+ */
+ STANDBY,
+ /**
+ * cluster is out of service (
+ */
+ OUT_OF_SERVICE,
+ /**
+ * cluster is single
+ */
+ SINGLE,
+ /**
+ * cluster initial status
+ */
+ NONE
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.LogCategorySet;
+
+/**
+ * /usr/sbin/l7directored control class
+ *
+ * @author nakai
+ * @versin 1.0
+ *
+ */
+public class DirectorController implements Serializable {
+ static final long serialVersionUID = 1L;
+
+ private final String l7directord = "/usr/sbin/l7directord";
+
+ protected String filename = "";
+
+ protected String CHECKTIMEOUT_KEY = "checktimeout";
+
+ protected String CHECKINTERVAL_KEY = "checkinterval";
+
+ protected String CHECKCOUNT_KEY = "checkcount";
+
+ protected String FALLBACK_KEY = "fallback";
+
+ protected String AUTORELOAD_KEY = "autoreload";
+
+ protected String EXECUTE_KEY = "execute";
+
+ protected String LOGFILE_KEY = "logfile";
+
+ protected String QUIESCENT_KEY = "quiescent";
+
+ protected String CALLBACK_KEY = "callback";
+
+ protected String NEGOTIATE_TIMEOUT_KEY = "negotiatetimeout";
+
+ protected String SUPERVISED_KEY = "supervised";
+
+ protected String VIRTUAL_KEY = "virtual";
+
+ protected String CHECKTYPE_KEY = "checktype";
+
+ protected String CHECKPORT_KEY = "checkport";
+
+ protected String MAXCONN_KEY = "maxconn";
+
+ protected String MODULE_KEY = "module";
+
+ protected String PROTOCOL_KEY = "protocol";
+
+ protected String QOSCLIENTS_KEY = "qosclients";
+
+ protected String QOSSERVICE_KEY = "qosservice";
+
+ protected String RECEIVE_KEY = "receive";
+
+ protected String SERVICE_KEY = "service";
+
+ protected String REAL_KEY = "real";
+
+ protected String REQUEST_KEY = "request";
+
+ protected String SCHEDULER_KEY = "scheduler";
+
+ protected String SORRYSERVER_KEY = "sorryserver";
+
+ protected String HTTPMETHOD_KEY = "httpmethod";
+
+ protected String VIRTUALHOST_KEY = "virtualhost";
+
+ protected String PASSWORD_KEY = "passwd";
+
+ protected String LOGIN_KEY = "login";
+
+ protected String DATABASE_KEY = "database";
+
+ protected String REALDOWNCALLBACK_KEY = "realdowncallback";
+
+ protected String REALRECOVERCALLBACK_KEY = "realrecovercallback";
+
+ /**
+ * pair class
+ * <p>
+ * class pair
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author kubota
+ */
+ protected class Pair<E, N> {
+ protected E elementFirst;
+
+ protected N elementSecond;
+
+ public Pair(E firstIn, N secondIn) {
+ elementFirst = firstIn;
+ elementSecond = secondIn;
+ }
+
+ public void set(E firstIn, N secondIn) {
+ elementFirst = firstIn;
+ elementSecond = secondIn;
+ }
+
+ public E first() {
+ return elementFirst;
+ }
+
+ public N second() {
+ return elementSecond;
+ }
+ }
+
+ protected Pair<String, String> paseKey(String inLine) {
+ if (inLine == null)
+ return null;
+ int pos = inLine.indexOf("=");
+ if (pos == -1)
+ return new Pair(inLine, "");
+ String first = inLine.substring(0, pos);
+ String second = inLine.substring(pos + 1, inLine.length());
+ if (first.indexOf('#') != -1)
+ return new Pair<String, String>("", "");
+ if (second.indexOf('#') != -1) {
+ pos = second.indexOf('#');
+ second = second.substring(0, pos);
+ }
+ first = first.trim();
+ second = second.trim();
+ Pair<String, String> pair = new Pair<String, String>(first, second);
+ return pair;
+ }
+
+ protected boolean serchfile() {
+ // sengenbasyo kentou yousu
+ final String confname = "l7directord.cf";
+ final String confdir1 = "/etc/ha.d/";
+ final String confdir2 = "/etc/ha.d/conf/";
+ String conf = confdir1 + confname;
+ File objFile = new File(conf);
+ if (!objFile.exists()) {
+ conf = confdir2 + confname;
+ objFile = new File(conf);
+ if (!objFile.exists()) {
+ return false;
+ }
+ }
+ if (!objFile.isFile()) {
+ return false;
+ }
+ filename = objFile.getPath();
+ return true;
+ }
+
+ private static String trimQuote(String s) {
+ if (s != null && s.matches("^\".*\"$")) {
+ s = s.substring(1, s.length() - 1);
+ }
+ return s;
+ }
+
+ protected DirectorData loadFromFile()
+ throws org.ultramonkey.l7.model.FileNotReadException {
+ DirectorData data;
+ try {
+ java.io.FileReader file = new java.io.FileReader(filename);
+ java.io.BufferedReader reader = new java.io.BufferedReader(file);
+ String buffer;
+ data = new DirectorData();
+ Stack<String> stack = new Stack<String>();
+ int position = 0;
+ while ((buffer = reader.readLine()) != null) {
+ buffer = buffer.replaceAll("\\s+$", "");
+ buffer = buffer.replaceAll("\\t", " ");
+ if (buffer.length() == 0 || buffer.matches("^\\s*#.*"))
+ continue;
+ if (buffer.indexOf(VIRTUAL_KEY) == 0)
+ position++;
+ stack.push(buffer);
+ }
+ String tmpGlobalLogFile = "";
+ String tmpGlobalExecute = "";
+ boolean tmpGlobalAutoreaload = false;
+ String tmpGlobalCallback = "";
+ String tmpGlobalFallback = "";
+ String tmpGlobalCheckInterval = "";
+ String tmpGlobalCheckTimeOut = "";
+ String tmpGlobalCheckCount = "";
+ String tmpGlobalNegotiateTimeOut = "";
+ String tmpGlobalQuiescent = "";
+ String tmpGlobalSupervised = "no";
+ String tmpCheckTimeOut = "";
+ String tmpCheckCount = "";
+ String tmpNegotiateTimeOut = "";
+ String tmpQuiescent = "";
+ String tmpQosClients = "";
+ String tmpQosService = "";
+ String tmpSorryServer = "";
+ String tmpMaxConn = "";
+ String tmpProtocol = "";
+ String tmpScheduler = "";
+ String tmpReceive = "";
+ String tmpRequest = "";
+ String tmpService = "";
+ String tmpModule = "";
+ Vector<String> tmpReal = new Vector<String>();
+ String tmpCheckType = "";
+ String tmpCheckport = "";
+ String tmpHttpMethod = "";
+ String tmpVirtualHost = "";
+ String tmpPassword = "";
+ String tmpLogin = "";
+ String tmpDatabase = "";
+ String tmpRealDownCallback = "";
+ String tmpRealRecoverCallback = "";
+ while (!stack.empty()) {
+ buffer = stack.pop();
+ if (buffer.indexOf(AUTORELOAD_KEY) == 0) {
+ Pair<String, String> pair = paseKey(buffer);
+ if (pair.second().indexOf("yes") != -1)
+ tmpGlobalAutoreaload = true;
+ else
+ tmpGlobalAutoreaload = false;
+ }
+ if (buffer.indexOf(CALLBACK_KEY) == 0) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpGlobalCallback = trimQuote(pair.second());
+ } else if (buffer.indexOf(CHECKTIMEOUT_KEY) == 0) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpGlobalCheckTimeOut = pair.second();
+ } else if (buffer.indexOf(CHECKINTERVAL_KEY) == 0) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpGlobalCheckInterval = pair.second();
+ } else if (buffer.indexOf(CHECKCOUNT_KEY) == 0) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpGlobalCheckCount = pair.second();
+ } else if (buffer.indexOf(FALLBACK_KEY) == 0) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpGlobalFallback = pair.second();
+ } else if (buffer.indexOf(EXECUTE_KEY) == 0) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpGlobalExecute = trimQuote(pair.second());
+ } else if (buffer.indexOf(LOGFILE_KEY) == 0) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpGlobalLogFile = trimQuote(pair.second());
+ } else if (buffer.indexOf(NEGOTIATE_TIMEOUT_KEY) == 0) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpGlobalNegotiateTimeOut = pair.second();
+ } else if (buffer.indexOf(QUIESCENT_KEY) == 0) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpGlobalQuiescent = pair.second();
+ } else if (buffer.indexOf(SUPERVISED_KEY) == 0) {
+ tmpGlobalSupervised = "yes";
+ } else if (buffer.indexOf(CHECKTIMEOUT_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpCheckTimeOut = pair.second();
+ } else if (buffer.indexOf(CHECKCOUNT_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpCheckCount = pair.second();
+ } else if (buffer.indexOf(NEGOTIATE_TIMEOUT_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpNegotiateTimeOut = pair.second();
+ } else if (buffer.indexOf(QUIESCENT_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpQuiescent = pair.second();
+ } else if (buffer.indexOf(CHECKTYPE_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpCheckType = pair.second();
+ } else if (buffer.indexOf(CHECKPORT_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpCheckport = pair.second();
+ } else if (buffer.indexOf(MAXCONN_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpMaxConn = pair.second();
+ } else if (buffer.indexOf(MODULE_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpModule = pair.second();
+ } else if (buffer.indexOf(PROTOCOL_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpProtocol = pair.second();
+ } else if (buffer.indexOf(QOSCLIENTS_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpQosClients = pair.second();
+ } else if (buffer.indexOf(QOSSERVICE_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpQosService = pair.second();
+ } else if (buffer.indexOf(REAL_KEY) >= 4
+ && buffer.indexOf(REALRECOVERCALLBACK_KEY) == -1
+ && buffer.indexOf(REALDOWNCALLBACK_KEY) == -1) {
+ Pair<String, String> pair = paseKey(buffer);
+ String real = pair.second();
+ tmpReal.add(real);
+ } else if (buffer.indexOf(RECEIVE_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpReceive = trimQuote(pair.second());
+ } else if (buffer.indexOf(REQUEST_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpRequest = trimQuote(pair.second());
+ } else if (buffer.indexOf(SCHEDULER_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpScheduler = pair.second();
+ } else if (buffer.indexOf(SERVICE_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpService = trimQuote(pair.second());
+ } else if (buffer.indexOf(HTTPMETHOD_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpHttpMethod = pair.second();
+ } else if (buffer.indexOf(VIRTUALHOST_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpVirtualHost = trimQuote(pair.second());
+ } else if (buffer.indexOf(PASSWORD_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpPassword = trimQuote(pair.second());
+ } else if (buffer.indexOf(LOGIN_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpLogin = trimQuote(pair.second());
+ } else if (buffer.indexOf(DATABASE_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpDatabase = trimQuote(pair.second());
+ } else if (buffer.indexOf(SORRYSERVER_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpSorryServer = pair.second();
+ } else if (buffer.indexOf(REALDOWNCALLBACK_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpRealDownCallback = trimQuote(pair.second());
+ } else if (buffer.indexOf(REALRECOVERCALLBACK_KEY) >= 4) {
+ Pair<String, String> pair = paseKey(buffer);
+ tmpRealRecoverCallback = trimQuote(pair.second());
+ } else if (buffer.indexOf(VIRTUAL_KEY) == 0) {
+ Pair<String, String> pair = paseKey(buffer);
+ VirtualSetting vs = new VirtualSetting();
+ int pos = pair.second().indexOf(":");
+ vs.virtual.host = pair.second().substring(0, pos);
+ vs.virtual.port = pair.second().substring(pos + 1,
+ pair.second().length());
+ if (! vs.virtual.port.matches("^\\d+$"))
+ vs.virtual.port = GetServ.byName(vs.virtual.port, "tcp");
+ for (Iterator<String> itr = tmpReal.iterator(); itr
+ .hasNext();) {
+ String realstr = itr.next();
+ pos = realstr.indexOf(":");
+ EndPoint ed = new EndPoint();
+ ed.host = realstr.substring(0, pos);
+ int spacepos = realstr.lastIndexOf(" ");
+ String tmpWeight = "";
+ if (spacepos == -1) {
+ ed.port = realstr.substring(pos + 1, realstr
+ .length());
+ } else {
+ ed.port = realstr.substring(pos + 1, spacepos).replaceAll(" masq", "");
+ tmpWeight = realstr.substring(spacepos + 1, realstr
+ .length());
+ }
+ if (! ed.port.matches("^\\d+$"))
+ ed.port = GetServ.byName(ed.port, "tcp");
+
+ if (tmpWeight.length() != 0) {
+ try {
+ ed.weight = Integer.parseInt(tmpWeight);
+ } catch (java.lang.NumberFormatException e) {
+ ed.weight = 1;
+ }
+ }
+ vs.real.add(ed);
+ }
+ vs.checktype = tmpCheckType;
+ if (tmpMaxConn.length() != 0)
+ vs.maxconn = Integer.parseInt(tmpMaxConn);
+ pos = tmpModule.indexOf(" ");
+ if (pos != -1) {
+ vs.protomod = tmpModule.substring(0, pos);
+ vs.option = tmpModule
+ .substring(pos + 1, tmpModule.length());
+ } else {
+ vs.protomod = tmpModule;
+ vs.option = "";
+ }
+ vs.protocol = tmpProtocol;
+ if (tmpQosClients.length() != 0) {
+ if ((pos = tmpQosClients.indexOf('k')) != -1
+ || (pos = tmpQosClients.indexOf('K')) != -1) {
+ vs.qosclient = Long.parseLong(tmpQosClients
+ .substring(0, pos));
+ vs.qosclient = vs.qosclient * 1000;
+ } else if ((pos = tmpQosClients.indexOf('M')) != -1
+ || (pos = tmpQosClients.indexOf('m')) != -1) {
+ vs.qosclient = Long.parseLong(tmpQosClients
+ .substring(0, pos));
+ vs.qosclient = vs.qosclient * 1000000;
+ } else {
+ vs.qosclient = Long.parseLong(tmpQosClients);
+ }
+ }
+ // QoSService
+ if (tmpQosService.length() != 0) {
+ if ((pos = tmpQosService.indexOf('K')) != -1
+ || (pos = tmpQosService.indexOf('k')) != -1) {
+ vs.qosservice = Long.parseLong(tmpQosService
+ .substring(0, pos));
+ vs.qosservice = vs.qosservice * 1000;
+ } else if ((pos = tmpQosService.indexOf('M')) != -1
+ || (pos = tmpQosService.indexOf('m')) != -1) {
+ vs.qosservice = Long.parseLong(tmpQosService
+ .substring(0, pos));
+ vs.qosservice = vs.qosservice * 1000000;
+ } else {
+ vs.qosservice = Long.parseLong(tmpQosService);
+ }
+ }
+ vs.receive = tmpReceive;
+ vs.service = tmpService;
+ vs.request = tmpRequest;
+ vs.sched = tmpScheduler;
+ pos = tmpSorryServer.indexOf(":");
+ if (pos != -1) {
+ vs.sorryserver.host = tmpSorryServer.substring(0, pos);
+ vs.sorryserver.port = tmpSorryServer.substring(pos + 1,
+ tmpSorryServer.length());
+ if (! vs.sorryserver.port.matches("^\\d+$"))
+ vs.sorryserver.port = GetServ.byName(vs.sorryserver.port, "tcp");
+ }
+ vs.quiescent = tmpQuiescent;
+ vs.upcallback = tmpRealRecoverCallback;
+ vs.downcallback = tmpRealDownCallback;
+ if (tmpCheckport.length() != 0)
+ vs.checkport = Integer.parseInt(tmpCheckport);
+ vs.httpmethod = tmpHttpMethod;
+ vs.virtualhost = tmpVirtualHost;
+ vs.login = tmpLogin;
+ vs.database = tmpDatabase;
+ vs.passwd = tmpPassword;
+ if (tmpCheckType != null &&
+ ((tmpCheckType.equals("connect") || tmpCheckType.equals("ping")) ||
+ ((tmpCheckType.equals("negotiate") || tmpCheckType.matches("^\\d$")) &&
+ tmpService != null && (tmpService.equals("dns") || tmpService.equals("sip"))
+ )
+ )
+ ) {
+ if (tmpCheckTimeOut.matches("^\\d+$"))
+ vs.timeout = Integer.parseInt(tmpCheckTimeOut);
+ }
+ else {
+ if (tmpNegotiateTimeOut.matches("^\\d+$"))
+ vs.timeout = Integer.parseInt(tmpNegotiateTimeOut);
+ }
+ if (tmpCheckCount.matches("^\\d+$"))
+ vs.checkcount = Integer.parseInt(tmpCheckCount);
+ vs.cfPosition = position;
+ position--;
+ data.virtualSettings.add(vs);
+ tmpCheckTimeOut = "";
+ tmpCheckCount = "";
+ tmpNegotiateTimeOut = "";
+ tmpQuiescent = "";
+ tmpQosClients = "";
+ tmpQosService = "";
+ tmpSorryServer = "";
+ tmpMaxConn = "";
+ tmpProtocol = "";
+ tmpScheduler = "";
+ tmpReceive = "";
+ tmpRequest = "";
+ tmpService = "";
+ tmpModule = "";
+ tmpReal = new Vector<String>();
+ tmpCheckType = "";
+ tmpCheckport = "";
+ tmpHttpMethod = "";
+ tmpVirtualHost = "";
+ tmpPassword = "";
+ tmpLogin = "";
+ tmpDatabase = "";
+ tmpRealDownCallback = "";
+ tmpRealRecoverCallback = "";
+ }// keyif if
+ }// while(stack)
+ data.autoreload = tmpGlobalAutoreaload;
+ data.callback = tmpGlobalCallback;
+ data.checkCount = tmpGlobalCheckCount;
+ data.checkInterval = tmpGlobalCheckInterval;
+ data.checkTimeOut = tmpGlobalCheckTimeOut;
+ data.fallback = tmpGlobalFallback;
+ data.logfile = tmpGlobalLogFile;
+ data.execute = tmpGlobalExecute;
+ data.negotiateTimeOut = tmpGlobalNegotiateTimeOut;
+ data.quiescent = tmpGlobalQuiescent;
+ data.supervised = tmpGlobalSupervised;
+ } catch (Exception e) {
+ org.ultramonkey.l7.model.FileNotReadException ex = new org.ultramonkey.l7.model.FileNotReadException();
+ throw ex;
+ }
+
+ return data;
+ }
+
+ /**
+ *
+ * <p>
+ * buildNewConf method
+ * </p>
+ *
+ * @param in
+ * @return new configuration lines
+ * @throws org.ultramonkey.l7.model.FileNotWriteException
+ */
+ protected LinkedList<String> buildNewConf(DirectorData in)
+ throws org.ultramonkey.l7.model.FileNotWriteException {
+ LinkedList<String> datas = new LinkedList();
+ try {
+ java.io.FileReader file = new java.io.FileReader(filename);
+ java.io.BufferedReader reader = new java.io.BufferedReader(file);
+ String buffer;
+ while ((buffer = reader.readLine()) != null) {
+ datas.addLast(buffer);
+ }
+ } catch (Exception e) {
+ org.ultramonkey.l7.model.FileNotWriteException ex = new org.ultramonkey.l7.model.FileNotWriteException();
+ ex.setErrMessage("Cannot open file : " + filename);
+ throw ex;
+ }
+
+ try {
+ HashMap<String, String> map = new HashMap<String, String>();
+ map.put(CHECKTIMEOUT_KEY, in.checkTimeOut);
+ map.put(CHECKINTERVAL_KEY, in.checkInterval);
+ map.put(CHECKCOUNT_KEY, in.checkCount);
+ map.put(FALLBACK_KEY, in.fallback);
+ if (in.autoreload)
+ map.put(AUTORELOAD_KEY, "yes");
+ else
+ map.put(AUTORELOAD_KEY, "no");
+ if (in.logfile != null && in.logfile.length() > 0)
+ map.put(LOGFILE_KEY, "\"" + in.logfile + "\"");
+ else
+ map.put(LOGFILE_KEY, null);
+ if (in.execute != null && in.execute.length() > 0)
+ map.put(EXECUTE_KEY, "\"" + in.execute + "\"");
+ else
+ map.put(EXECUTE_KEY, null);
+ map.put(QUIESCENT_KEY, in.quiescent);
+ if (in.callback != null && in.callback.length() > 0)
+ map.put(CALLBACK_KEY, "\"" + in.callback + "\"");
+ else
+ map.put(CALLBACK_KEY, null);
+ map.put(NEGOTIATE_TIMEOUT_KEY, in.negotiateTimeOut);
+ if (in.supervised != null && in.supervised.equals("yes"))
+ map.put(SUPERVISED_KEY, in.supervised);
+ else
+ map.put(SUPERVISED_KEY, null);
+
+ // global datas
+ for (Iterator<String> itr = map.keySet().iterator(); itr.hasNext();) {
+ String key = itr.next();
+ String value = map.get(key);
+ int commentLines = 0;
+ boolean inserted = false;
+ for (int i = 0; i < datas.size(); ++i) {
+ String line = datas.get(i);
+ String buffer = line.replaceAll("\\s+$", "");
+ if (buffer.length() == 0 || buffer.matches("^\\s*#.*")) {
+ commentLines++;
+ continue;
+ }
+ else if (buffer.indexOf(VIRTUAL_KEY) == 0) {
+ if (value != null && value.length() > 0) {
+ StringBuffer buf = new StringBuffer(key);
+ if (! key.equals(SUPERVISED_KEY)) {
+ buf.append("=");
+ buf.append(value);
+ }
+ datas.add(i - commentLines, buf.toString());
+ }
+ inserted = true;
+ break;
+ }
+ commentLines = 0;
+ Pair<String, String> pair = paseKey(buffer);
+ if (pair.first().equals(key)) {
+ if (value == null || ! pair.second().equals(value)) {
+ StringBuffer buf = new StringBuffer("#");
+ buf.append(buffer);
+ datas.set(i, buf.toString());
+ if (value != null && value.length() > 0) {
+ buf = new StringBuffer();
+ buf.append(key);
+ if (! key.equals(SUPERVISED_KEY)) {
+ buf.append("=");
+ buf.append(value);
+ }
+ datas.add(i, buf.toString());
+ }
+ }
+ inserted = true;
+ break;
+ }
+ }
+ if (inserted == false) {
+ if (value != null && value.length() > 0) {
+ StringBuffer buf = new StringBuffer(key);
+ if (! key.equals(SUPERVISED_KEY)) {
+ buf.append("=");
+ buf.append(value);
+ }
+ datas.add(buf.toString());
+ }
+ }
+ }
+ // virtual settings
+ DirectorData currentData = null;
+ currentData = this.loadFromFile();
+ LinkedList<Integer> delVsPosition = new LinkedList<Integer>();
+ LinkedList<VirtualSetting> addVs = new LinkedList<VirtualSetting>();
+ for (Iterator<VirtualSetting> itr = in.virtualSettings
+ .iterator(); itr.hasNext();) {
+ VirtualSetting vs = itr.next();
+ boolean sameFlag = false;
+ for (Iterator<VirtualSetting> curItr = currentData.virtualSettings
+ .iterator(); curItr.hasNext();) {
+ VirtualSetting curVs = curItr.next();
+ if (curVs.equals(vs)) {
+ sameFlag = true;
+ curVs.cfPosition = 0;
+ break;
+ }
+ }
+ if (sameFlag == false) {
+ addVs.add(vs);
+ }
+ }
+ for (Iterator<VirtualSetting> curItr = currentData.virtualSettings
+ .iterator(); curItr.hasNext();) {
+ VirtualSetting curVs = curItr.next();
+ if (curVs.cfPosition != 0)
+ delVsPosition.add(curVs.cfPosition);
+ }
+
+ int position = 0;
+ int commentLines = 0;
+ for (int i = 0; i < datas.size(); ++i) {
+ String buffer = datas.get(i);
+ String line = buffer.replaceAll("\\s+$", "");
+ if (line.length() == 0 || line.matches("^\\s*#.*")) {
+ continue;
+ }
+ else if (buffer.indexOf(VIRTUAL_KEY) == 0) {
+ position++;
+ if (delVsPosition.contains(position)) {
+ int vsStartLine = i;
+ for (; i < datas.size(); ++i) {
+ buffer = datas.get(i);
+ line = buffer.replaceAll("\\s+$", "");
+ if (line.length() == 0 || line.matches("^\\s*#.*")) {
+ commentLines++;
+ continue;
+ }
+ if (buffer.indexOf(VIRTUAL_KEY) == 0 && i != vsStartLine) {
+ i -= 1 + commentLines;
+ commentLines = 0;
+ break;
+ }
+ commentLines = 0;
+ StringBuffer buf = new StringBuffer("#");
+ buf.append(datas.get(i));
+ datas.set(i, buf.toString());
+ }
+ }
+ }
+ }
+ for (VirtualSetting vs : addVs) {
+ datas.add(VIRTUAL_KEY + "=" + vs.virtual.host
+ + ":" + vs.virtual.port);
+ if (vs.real.size() != 0) {
+ for (java.util.Iterator<EndPoint> realitr = vs.real
+ .iterator(); realitr.hasNext();) {
+ EndPoint endpoint = realitr.next();
+ datas.add("\t" + REAL_KEY + "=" + endpoint.host
+ + ":" + endpoint.port + " masq "
+ + String.valueOf(endpoint.weight));
+ }
+ }
+ if (vs.checktype.length() != 0)
+ datas.add("\t" + CHECKTYPE_KEY + "=" + vs.checktype);
+ if (vs.checkport != 0)
+ datas.add("\t" + CHECKPORT_KEY + "=" + vs.checkport);
+ if (vs.maxconn != 0)
+ datas.add("\t" + MAXCONN_KEY + "="
+ + String.valueOf(vs.maxconn));
+ if (vs.protomod.length() != 0)
+ datas.add("\t" + MODULE_KEY + "=" + vs.protomod + " "
+ + vs.option);
+ if (vs.qosclient != 0) {
+ StringBuffer buf = new StringBuffer();
+ if (vs.qosclient > 1000000) {
+ buf.append(vs.qosclient / 1000000);
+ buf.append('M');
+ } else if (vs.qosclient > 1000) {
+ buf.append(vs.qosclient / 1000);
+ buf.append('K');
+ } else
+ buf.append(vs.qosclient);
+ datas.add("\t" + QOSCLIENTS_KEY + "="
+ + buf.toString());
+ }
+ if (vs.qosservice != 0) {
+ StringBuffer buf = new StringBuffer();
+ if (vs.qosservice > 1000000) {
+ buf.append(vs.qosservice / 1000000);
+ buf.append('M');
+ } else if (vs.qosservice > 1000) {
+ buf.append(vs.qosservice / 1000);
+ buf.append('K');
+ } else
+ buf.append(vs.qosservice);
+ datas.add("\t" + QOSSERVICE_KEY + "="
+ + buf.toString());
+ }
+ if (vs.receive.length() != 0)
+ datas.add("\t" + RECEIVE_KEY + "=\"" + vs.receive + "\"");
+ if (vs.service.length() != 0)
+ datas.add("\t" + SERVICE_KEY + "=\"" + vs.service + "\"");
+ if (vs.request.length() != 0)
+ datas.add("\t" + REQUEST_KEY + "=\"" + vs.request + "\"");
+ if (vs.sched.length() != 0)
+ datas.add("\t" + SCHEDULER_KEY + "=" + vs.sched);
+ if (vs.sorryserver.host.length() != 0)
+ datas.add("\t" + SORRYSERVER_KEY + "="
+ + vs.sorryserver.host + ":" + vs.sorryserver.port);
+ if (vs.httpmethod.length() != 0)
+ datas.add("\t" + HTTPMETHOD_KEY + "=" + vs.httpmethod);
+ if (vs.virtualhost.length() != 0)
+ datas.add("\t" + VIRTUALHOST_KEY + "=\"" + vs.virtualhost + "\"");
+ if (vs.passwd.length() != 0)
+ datas.add("\t" + PASSWORD_KEY + "=\"" + vs.passwd + "\"");
+ if (vs.login.length() != 0)
+ datas.add("\t" + LOGIN_KEY + "=\"" + vs.login + "\"");
+ if (vs.database.length() != 0)
+ datas.add("\t" + DATABASE_KEY + "=\"" + vs.database + "\"");
+ if (vs.downcallback.length() != 0)
+ datas.add("\t" + REALDOWNCALLBACK_KEY + "=\""
+ + vs.downcallback + "\"");
+ if (vs.upcallback.length() != 0)
+ datas.add("\t" + REALRECOVERCALLBACK_KEY + "=\""
+ + vs.upcallback + "\"");
+// if (vs.checkcount != 0)
+// datas.add("\t" + CHECKCOUNT_KEY + "=" + vs.checkcount);
+ if (vs.timeout != 0) {
+ if (vs.checktype != null &&
+ ((vs.checktype.equals("connect") || vs.checktype.equals("ping")) ||
+ ((vs.checktype.equals("negotiate") || vs.checktype.matches("^\\d$")) &&
+ vs.service != null && (vs.service.equals("dns") || vs.service.equals("sip"))
+ )
+ )
+ ) {
+ datas.add("\t" + CHECKTIMEOUT_KEY + "=" + vs.timeout);
+ }
+ else {
+ datas.add("\t" + NEGOTIATE_TIMEOUT_KEY + "=" + vs.timeout);
+ }
+ }
+ if (vs.quiescent.length() != 0)
+ datas.add("\t" + QUIESCENT_KEY + "=" + vs.quiescent);
+ if (vs.protocol.length() != 0)
+ datas.add("\t" + PROTOCOL_KEY + "=" + vs.protocol);
+ datas.add("");
+ }
+ } catch (Exception e) {
+ org.ultramonkey.l7.model.FileNotWriteException ex = new org.ultramonkey.l7.model.FileNotWriteException();
+ ex.setErrMessage("Cannot open file : " + filename
+ + "BaseException : " + e.getMessage());
+ throw ex;
+ }
+
+ return datas;
+ }
+
+ /**
+ *
+ * <p>
+ * saveToFile method
+ * </p>
+ *
+ * @param in
+ * @throws org.ultramonkey.l7.model.FileNotWriteException
+ */
+ protected void saveToFile(DirectorData in)
+ throws org.ultramonkey.l7.model.FileNotWriteException {
+ LinkedList<String> datas = this.buildNewConf(in);
+ try {
+ java.io.File file = new java.io.File(filename);
+ if (file.exists()) {
+ Date date = new Date();
+ java.io.File backfile = new java.io.File(filename + ".bak."
+ + String.valueOf(date.getTime()));
+ file.renameTo(backfile);
+ file = new java.io.File(filename);
+ }
+ java.io.FileWriter writer = new java.io.FileWriter(file);
+ for (Iterator<String> itr = datas.iterator(); itr
+ .hasNext();) {
+ StringBuffer buf = new StringBuffer(itr.next());
+ buf.append('\n');
+ writer.write(buf.toString());
+ }
+ writer.flush();
+ writer.close();
+ } catch (Exception e) {
+ org.ultramonkey.l7.model.FileNotWriteException ex = new org.ultramonkey.l7.model.FileNotWriteException();
+ ex.setErrMessage("Cannot write file : " + filename);
+ throw ex;
+ }
+ }
+
+ /**
+ *
+ * <p>
+ * syntaxCheck method
+ * </p>
+ *
+ * @param in
+ * @throws org.ultramonkey.l7.model.FileNotWriteException
+ */
+ protected String syntaxCheck(DirectorData in)
+ throws org.ultramonkey.l7.model.FileNotWriteException {
+ StringBuffer result = new StringBuffer();
+ LinkedList<String> datas = this.buildNewConf(in);
+ try {
+ Date date = new Date();
+ String tmpFile = filename + "." + String.valueOf(date.getTime());
+ File file = new java.io.File(tmpFile);
+ FileWriter writer = new FileWriter(file);
+ for (Iterator<String> itr = datas.iterator(); itr
+ .hasNext();) {
+ StringBuffer buf = new StringBuffer(itr.next());
+ buf.append('\n');
+ writer.write(buf.toString());
+ }
+ writer.flush();
+ writer.close();
+
+ // TODO sudo
+ String command = "sudo " + l7directord + " -t " + tmpFile;
+ Process p = Runtime.getRuntime().exec(command);
+ InputStream stderr = p.getErrorStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(stderr));
+ String line = null;
+ while ((line = br.readLine()) != null) {
+ result.append(line + "\n");
+ }
+ InputStream is = p.getInputStream();
+ br = new BufferedReader(new InputStreamReader(is));
+ while ((line = br.readLine()) != null) {
+ result.append(line + "\n");
+ }
+
+ file.delete();
+ } catch (Exception e) {
+ org.ultramonkey.l7.model.FileNotWriteException ex = new org.ultramonkey.l7.model.FileNotWriteException();
+ ex.setErrMessage("Cannot write file : " + filename);
+ throw ex;
+ }
+
+ return result.toString();
+ }
+
+ /**
+ * get DirectorData from l7directord.cf
+ * <p>
+ * getDirectorData method
+ * </p>
+ *
+ * @return DirectorData l7directord.cf datas
+ * @throws org.ultramonkey.l7.model.FileNotReadException
+ */
+ public DirectorData getDirectorData()
+ throws org.ultramonkey.l7.model.FileNotReadException {
+ // --- debug log (in method) ---
+ Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE);
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11575 DirectorController::getDirectorData() in");
+ }
+ // --- debug log (in method) ---
+
+ DirectorData data = null;
+ synchronized (this) {
+ if (serchfile()) {
+ data = loadFromFile();
+ }
+ }
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11576 DirectorController::getDirectorData() out return=(" + data + ")");
+ }
+ // --- debug log (out method) ---
+ return data;
+ }
+
+ /**
+ * set DirectorData to l7directord.cf
+ * <p>
+ * setDirectorData method
+ * </p>
+ *
+ * @param in
+ */
+ public void setDirectorData(DirectorData in)
+ throws org.ultramonkey.l7.model.FileNotWriteException {
+ // --- debug log (in method) ---
+ Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE);
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11577 DirectorController::setDirectorData(DirectorData in) in in=(" + in + ")");
+ }
+ // --- debug log (in method) ---
+
+ synchronized (this) {
+ if (in != null && serchfile()) {
+ saveToFile(in);
+ }
+ }
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11578 DirectorController::setDirectorData(DirectorData in) out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ /**
+ * check new l7directord.cf
+ * <p>
+ * checkDirectorData method
+ * </p>
+ *
+ * @param in
+ */
+ public String checkDirectorData(DirectorData in)
+ throws org.ultramonkey.l7.model.FileNotWriteException {
+ // --- debug log (in method) ---
+ Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE);
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11579 DirectorController::checkDirectorData(DirectorData in) in in=(" + in + ")");
+ }
+ // --- debug log (in method) ---
+
+ synchronized (this) {
+ if (in != null && serchfile()) {
+ String ret = this.syntaxCheck(in);
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11580 DirectorController::checkDirectorData(DirectorData in) out return=\"" + ret + "\"");
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11581 DirectorController::checkDirectorData(DirectorData in) out return=null");
+ }
+ // --- debug log (out method) ---
+ return null;
+ }
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+import java.io.Serializable;
+import java.util.Vector;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.LogCategorySet;
+
+public class DirectorData implements Serializable {
+ static final long serialVersionUID = 1;
+
+ public String checkTimeOut;
+
+ public String negotiateTimeOut;
+
+ public String checkInterval;
+
+ public String checkCount;
+
+ public boolean autoreload;
+
+ public String callback;
+
+ public String fallback;
+
+ public String logfile;
+
+ public String execute;
+
+ public String supervised;
+
+ public String quiescent;
+
+ public Vector<VirtualSetting> virtualSettings;
+
+ public DirectorData() {
+ // --- debug log (constructor) ---
+ Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE);
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11582 class DirectorData created.");
+ }
+ // --- debug log (constructor) ---
+ this.autoreload = false;
+ this.callback = "";
+ this.checkCount = "";
+ this.checkInterval = "";
+ this.checkTimeOut = "";
+ this.execute = "";
+ this.fallback = "";
+ this.logfile = "";
+ this.negotiateTimeOut = "";
+ this.quiescent = "";
+ this.supervised = "";
+ this.virtualSettings = new Vector<VirtualSetting>();
+ }
+
+ public DirectorData( DirectorData inData ){
+ // --- debug log (constructor) ---
+ Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE);
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11583 class DirectorData created.");
+ }
+ // --- debug log (constructor) ---
+ this.autoreload = inData.autoreload;
+ this.callback = inData.callback;
+ this.checkCount = inData.checkCount;
+ this.checkInterval = inData.checkInterval;
+ this.checkTimeOut = inData.checkTimeOut;
+ this.execute = inData.execute;
+ this.fallback = inData.fallback;
+ this.logfile = inData.logfile;
+ this.negotiateTimeOut = inData.negotiateTimeOut;
+ this.quiescent = inData.quiescent;
+ this.supervised = inData.supervised;
+ this.virtualSettings = inData.virtualSettings;
+ }
+
+ public boolean equals(DirectorData in) {
+ if( this.autoreload == in.autoreload &&
+ this.callback.equals(in.callback) &&
+ this.checkCount.equals(in.checkCount) &&
+ this.checkInterval.equals(in.checkInterval) &&
+ this.checkTimeOut.equals(in.checkTimeOut) &&
+ this.fallback.equals(in.fallback) &&
+ this.logfile.equals(in.logfile) &&
+ this.negotiateTimeOut.equals(in.negotiateTimeOut) &&
+ this.supervised.equals(in.supervised) &&
+ this.virtualSettings.equals(in.virtualSettings)){
+ return true;
+ }
+ return false;
+ }
+
+ public String toString() {
+ return
+ "checkTimeOut=\"" + this.checkTimeOut + "\", " +
+ "negotiateTimeOut=\"" + this.negotiateTimeOut + "\", " +
+ "checkInterval=\"" + this.checkInterval + "\", " +
+ "checkCount=\"" + this.checkCount + "\", " +
+ "autoreload=" + this.autoreload + ", " +
+ "callback=\"" + this.callback + "\", " +
+ "fallback=\"" + this.fallback + "\", " +
+ "logfile=\"" + this.logfile + "\", " +
+ "execute=\"" + this.execute + "\", " +
+ "supervised=\"" + this.supervised + "\", " +
+ "quiescent=\"" + this.quiescent + "\", " +
+ "virtualSettings=(" + this.virtualSettings + ")";
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+import java.io.Serializable;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.LogCategorySet;
+
+/**
+ *
+ * <p>
+ * class EndPoint
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author tanuma
+ */
+public class EndPoint implements Serializable {
+ static final long serialVersionUID = 1L;
+
+ /**
+ * IP address
+ */
+ public String host;
+
+ /**
+ * Port number
+ */
+ public String port;
+
+ /**
+ * Weight
+ */
+ public int weight;
+
+ /**
+ * Active connections
+ */
+ public long actConn;
+
+ /**
+ * Inactive connections
+ */
+ public long inActConn;
+
+ /**
+ *
+ * Constructor
+ *
+ */
+ public EndPoint() {
+ // --- debug log (constructor) ---
+ Logger vsLogger = Logger.getLogger(LogCategorySet.GUI_VIRTUALSERVICE);
+ if (vsLogger.isDebugEnabled()) {
+ vsLogger.debug("11513 class EndPoint created.");
+ }
+ // --- debug log (constructor) ---
+
+ host = "";
+ port = "";
+ weight = 0;
+ actConn = 0;
+ inActConn = 0;
+ }
+
+ /**
+ *
+ * Constructor for real server
+ *
+ * @param host
+ * @param port
+ * @param weight
+ * @param actConn
+ * @param inActConn
+ */
+ public EndPoint(String host, String port, int weight, long actConn,
+ long inActConn) {
+ // --- debug log (constructor) ---
+ Logger vsLogger = Logger.getLogger(LogCategorySet.GUI_VIRTUALSERVICE);
+ if (vsLogger.isDebugEnabled()) {
+ vsLogger.debug("11514 class EndPoint created.");
+ }
+ // --- debug log (constructor) ---
+
+ if (host == null)
+ this.host = "";
+ else
+ this.host = new String(host);
+ if (port == null)
+ this.port = "";
+ else
+ this.port = new String(port);
+ this.weight = weight;
+ this.actConn = actConn;
+ this.inActConn = inActConn;
+ }
+
+ /**
+ *
+ * Constructor for virtual service, sorry server
+ *
+ * @param host
+ * @param port
+ */
+ public EndPoint(String host, String port) {
+ // --- debug log (constructor) ---
+ Logger vsLogger = Logger.getLogger(LogCategorySet.GUI_VIRTUALSERVICE);
+ if (vsLogger.isDebugEnabled()) {
+ vsLogger.debug("11515 class EndPoint created.");
+ }
+ // --- debug log (constructor) ---
+
+ if (host == null)
+ this.host = "";
+ else
+ this.host = new String(host);
+ if (port == null)
+ this.port = "";
+ else
+ this.port = new String(port);
+ this.weight = 0;
+ this.actConn = 0;
+ this.inActConn = 0;
+ }
+
+ /**
+ *
+ * Copy Constructor
+ *
+ * @param e
+ */
+ public EndPoint(EndPoint e) {
+ // --- debug log (constructor) ---
+ Logger vsLogger = Logger.getLogger(LogCategorySet.GUI_VIRTUALSERVICE);
+ if (vsLogger.isDebugEnabled()) {
+ vsLogger.debug("11516 class EndPoint created.");
+ }
+ // --- debug log (constructor) ---
+
+ if (e == null) {
+ host = "";
+ port = "";
+ weight = 0;
+ actConn = 0;
+ inActConn = 0;
+ } else {
+ if (e.host != null)
+ this.host = new String(e.host);
+ if (e.port != null)
+ this.port = new String(e.port);
+ this.weight = e.weight;
+ this.actConn = e.actConn;
+ this.inActConn = e.inActConn;
+ }
+ }
+
+ /**
+ *
+ * <p>
+ * equals method
+ * </p>
+ *
+ * @param e
+ * @return
+ */
+ public boolean equals(EndPoint e) {
+ // --- debug log (in method) ---
+ Logger vsLogger = Logger.getLogger(LogCategorySet.GUI_VIRTUALSERVICE);
+ if (vsLogger.isDebugEnabled()) {
+ vsLogger.debug("11517 EndPoint::equals(EndPoint e) in e=(" + e + ")");
+ }
+ // --- debug log (in method) ---
+
+ if (e != null && this.host.equals(e.host) && this.port.equals(e.port)) {
+ // --- debug log (out method) ---
+ if (vsLogger.isDebugEnabled()) {
+ vsLogger.debug("11518 EndPoint::equals(EndPoint e) out return=true");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+
+ // --- debug log (out method) ---
+ if (vsLogger.isDebugEnabled()) {
+ vsLogger.debug("11519 EndPoint::equals(EndPoint e) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public String toString() {
+ return
+ "host=\"" + host + "\", " +
+ "port=\"" + port + "\", " +
+ "weight=" + weight + ", " +
+ "actConn=" + actConn + ", " +
+ "inActConn=" + inActConn;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+import java.util.regex.*;
+import java.io.*;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.LogCategorySet;
+
+/**
+ *
+ * <p>
+ * class GetServ
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author tanuma
+ */
+public class GetServ {
+
+ /**
+ * services filename
+ */
+ private static final String SERVICE_FILENAME = "/etc/services";
+
+ /**
+ *
+ * <p>
+ * byName method
+ * </p>
+ *
+ * @param name
+ * service name
+ * @param proto
+ * protocol name
+ * @return
+ */
+ public static String byName(String name, String proto) {
+ // --- debug log (in method) ---
+ Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE);
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger
+ .debug("11584 GetServ::byName(String name, String proto) in name=\""
+ + name + "\", proto=\"" + proto + "\"");
+ }
+ // --- debug log (in method) ---
+
+ if (name == null || proto == null) {
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger
+ .debug("11585 GetServ::byName(String name, String proto) out return=null");
+ }
+ // --- debug log (out method) ---
+ return null;
+ }
+
+ try {
+ String port = null;
+ String line;
+
+ String regex = "^([-_a-zA-Z0-9]+)\\s+(\\d+)/([-_a-zA-Z0-9]+)([-_a-zA-Z0-9\\s]+)*$";
+ Pattern p = Pattern.compile(regex);
+
+ BufferedReader br = new BufferedReader(new InputStreamReader(
+ new FileInputStream(SERVICE_FILENAME)));
+
+ while ((line = br.readLine()) != null && port == null) {
+ line = line.replaceAll("#.*", "");
+ if (line.length() != 0) {
+ Matcher m = p.matcher(line.trim());
+ if (m.matches() && m.group(3).equals(proto)) {
+ if (m.group(1).equals(name)) {
+ port = m.group(2);
+ } else if (m.group(4) != null) {
+ String[] aliases = m.group(4).split("\\s");
+ for (String alias : aliases) {
+ if (alias.equals(name)) {
+ port = m.group(2);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ br.close();
+ if (port != null) {
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11586 GetServ::byName(String name, String proto) out return=\"" + port + "\"");
+ }
+ // --- debug log (out method) ---
+ return port;
+ } else {
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11587 GetServ::byName(String name, String proto) out return=\"" + name + "\"");
+ }
+ // --- debug log (out method) ---
+ return name;
+ }
+ } catch (IOException ioe) {
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11588 GetServ::byName(String name, String proto) out return=null");
+ }
+ // --- debug log (out method) ---
+ return null;
+ }
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.*;
+import java.util.regex.*;
+import java.util.*;
+import java.io.*;
+
+/**
+ *
+ * <p>
+ * class L7vsAdmController
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author tanuma
+ */
+public class L7vsAdmController {
+ private static final String l7vsadm = "/usr/sbin/l7vsadm";
+
+ private Logger ioCommandLogger = Logger.getLogger(LogCategorySet.GUI_IO_COMMAND);
+
+ /**
+ *
+ * <p>
+ * addVirtualService method
+ * </p>
+ *
+ * @param vs
+ * @return result of l7vsadm add virtual service command.
+ */
+ public boolean addVirtualService(VirtualSetting vs) {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7vsAdmController::addVirtualService(VirtualSetting vs) in ");
+ buf.append("vs=(" + vs + ")");
+ ioCommandLogger.debug("11524 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ synchronized (this) {
+ if (vs == null || vs.virtual == null) {
+ ioCommandLogger.warn("31003 Invalid null argument.");
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11525 L7vsAdmController::addVirtualService(VirtualSetting vs) out return=false");
+ }
+ // --- debug log (in method) ---
+ return false;
+ }
+
+ StringBuffer command = new StringBuffer(l7vsadm + " -A -t "
+ + vs.virtual.host + ":" + vs.virtual.port + " -m "
+ + vs.protomod + " " + vs.option + " -s " + vs.sched);
+ if (vs.maxconn > 0) {
+ command.append(" -u " + vs.maxconn);
+ }
+ if (vs.sorryserver != null && vs.sorryserver.host.length() > 0 && vs.sorryserver.port.length() > 0) {
+ command.append(" -b " + vs.sorryserver.host + ":"
+ + vs.sorryserver.port);
+ }
+ if (vs.sorryflag == true) {
+ command.append(" -f 1");
+ }
+ if (vs.qosservice > 0) {
+ if (vs.qosservice >= 1000000000L) {
+ long qoss = vs.qosservice / 1000000000L;
+ command.append(" -Q " + qoss + "G");
+ }
+ else if (vs.qosservice >= 1000000L) {
+ long qoss = vs.qosservice / 1000000L;
+ command.append(" -Q " + qoss + "M");
+ }
+ else if (vs.qosservice >= 1000L) {
+ long qoss = vs.qosservice / 1000L;
+ command.append(" -Q " + qoss + "K");
+ }
+ else {
+ command.append(" -Q " + vs.qosservice);
+ }
+ }
+ if (vs.qosclient > 0) {
+ if (vs.qosclient >= 1000000000L) {
+ long qosc = vs.qosclient / 1000000000L;
+ command.append(" -q " + qosc + "G");
+ }
+ else if (vs.qosclient >= 1000000L) {
+ long qosc = vs.qosclient / 1000000L;
+ command.append(" -q " + qosc + "M");
+ }
+ else if (vs.qosclient >= 1000L) {
+ long qosc = vs.qosclient / 1000L;
+ command.append(" -q " + qosc + "K");
+ }
+ else {
+ command.append(" -q " + vs.qosclient);
+ }
+ }
+
+ String result = runProcess(command.toString());
+ if (result == null || result.length() != 0) {
+ ioCommandLogger.error("41220 Command error: command=" + command);
+ ioCommandLogger.error("41221 Command error: result=" + result);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11526 L7vsAdmController::addVirtualService(VirtualSetting vs) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ if (vs.real != null) {
+ for (int i = 0; i < vs.real.size(); i++) {
+ EndPoint real = vs.real.elementAt(i);
+ String realCommand = l7vsadm + " -a -t " + vs.virtual.host + ":" + vs.virtual.port + " -m "
+ + vs.protomod + " " + vs.option + " -r " + real.host + ":" + real.port + " -w " + real.weight;
+ result = runProcess(realCommand);
+
+ if (result == null || result.length() != 0) {
+ ioCommandLogger.error("41222 Command error: command=" + command);
+ ioCommandLogger.error("41223 Command error: result=" + result);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11527 L7vsAdmController::addVirtualService(VirtualSetting vs) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+ }
+ }
+
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11528 L7vsAdmController::addVirtualService(VirtualSetting vs) out return=true");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+ }
+
+ /**
+ *
+ * <p>
+ * delVirtualService method
+ * </p>
+ *
+ * @param vs
+ * @return result of l7vsadm delete virtual service command.
+ */
+ public boolean delVirtualService(VirtualSetting vs) {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7vsAdmController::delVirtualService(VirtualSetting vs) in ");
+ buf.append("vs=(" + vs + ")");
+ ioCommandLogger.debug("11529 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ synchronized (this) {
+ if (vs == null || vs.virtual == null) {
+ ioCommandLogger.warn("31004 Invalid null argument.");
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11530 L7vsAdmController::delVirtualService(VirtualSetting vs) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+ String command = l7vsadm + " -D -t " + vs.virtual.host + ":"
+ + vs.virtual.port + " -m " + vs.protomod + " " + vs.option;
+
+ String result = runProcess(command);
+ if (result == null || result.length() != 0) {
+ ioCommandLogger.error("41224 Command error: command=" + command);
+ ioCommandLogger.error("41225 Command error: result=" + result);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11531 L7vsAdmController::delVirtualService(VirtualSetting vs) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11532 L7vsAdmController::delVirtualService(VirtualSetting vs) out return=true");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+ }
+
+ /**
+ *
+ * <p>
+ * getData method
+ * </p>
+ *
+ * @return result of l7vsadm list command, including virtual service
+ * setting.
+ */
+ public L7vsAdmData getData() {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11533 L7vsAdmController::getData() in");
+ }
+ // --- debug log (in method) ---
+
+ synchronized (this) {
+ L7vsAdmData admData = new L7vsAdmData();
+
+ String command = l7vsadm + " -V -n";
+ String result = runProcess(command);
+
+ if (result == null) {
+ ioCommandLogger.error("41226 Command error: command=" + command);
+ ioCommandLogger.error("41227 Command error: result=null");
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11534 L7vsAdmController::getData() out return=null");
+ }
+ // --- debug log (out method) ---
+ return null;
+ }
+
+ // l7vsd log level regex
+ Pattern l7vsdLogLevel = Pattern.compile(
+ "^(l7vsd_[\\w\\.]+)\\s+(debug|info|warn|error|fatal)$",
+ Pattern.MULTILINE);
+ Matcher l7vsdLog = l7vsdLogLevel.matcher(result);
+ while (l7vsdLog.find()) {
+ LogData.LogLevel level;
+ if (l7vsdLog.group(2).equals("debug"))
+ level = LogData.LogLevel.DEBUG;
+ else if (l7vsdLog.group(2).equals("info"))
+ level = LogData.LogLevel.INFO;
+ else if (l7vsdLog.group(2).equals("warn"))
+ level = LogData.LogLevel.WARN;
+ else if (l7vsdLog.group(2).equals("error"))
+ level = LogData.LogLevel.ERROR;
+ else if (l7vsdLog.group(2).equals("fatal"))
+ level = LogData.LogLevel.FATAL;
+ else {
+ ioCommandLogger.info("21092 Unknown log level: " + l7vsdLog.group(2));
+ continue;
+ }
+
+ if (l7vsdLog.group(1).equals("l7vsd_network"))
+ admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_NETWORK,
+ level);
+ else if (l7vsdLog.group(1).equals("l7vsd_network.bandwidth"))
+ admData.l7vsdLogLevel.put(
+ LogData.LogCategory.L7VSD_NETWORK_BANDWIDTH, level);
+ else if (l7vsdLog.group(1).equals("l7vsd_network.num_connection"))
+ admData.l7vsdLogLevel
+ .put(LogData.LogCategory.L7VSD_NETWORK_NUM_CONNECTION,
+ level);
+ else if (l7vsdLog.group(1).equals("l7vsd_network.qos"))
+ admData.l7vsdLogLevel.put(
+ LogData.LogCategory.L7VSD_NETWORK_QOS, level);
+ else if (l7vsdLog.group(1).equals("l7vsd_virtual_service"))
+ admData.l7vsdLogLevel.put(
+ LogData.LogCategory.L7VSD_VIRTUAL_SERVICE, level);
+ else if (l7vsdLog.group(1).equals("l7vsd_real_server"))
+ admData.l7vsdLogLevel.put(
+ LogData.LogCategory.L7VSD_REAL_SERVER, level);
+ else if (l7vsdLog.group(1).equals("l7vsd_sorry_server"))
+ admData.l7vsdLogLevel.put(
+ LogData.LogCategory.L7VSD_SORRY_SERVER, level);
+ else if (l7vsdLog.group(1).equals("l7vsd_real_server.balancing"))
+ admData.l7vsdLogLevel.put(
+ LogData.LogCategory.L7VSD_REAL_SERVER_BALANCING, level);
+ else if (l7vsdLog.group(1).equals("l7vsd_replication"))
+ admData.l7vsdLogLevel.put(
+ LogData.LogCategory.L7VSD_REPLICATION, level);
+ else if (l7vsdLog.group(1).equals("l7vsd_start_stop"))
+ admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_START_STOP,
+ level);
+ else if (l7vsdLog.group(1).equals("l7vsd_system"))
+ admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_SYSTEM,
+ level);
+ else if (l7vsdLog.group(1).equals("l7vsd_system.memory"))
+ admData.l7vsdLogLevel.put(
+ LogData.LogCategory.L7VSD_SYSTEM_MEMORY, level);
+ else if (l7vsdLog.group(1).equals("l7vsd_system.socket"))
+ admData.l7vsdLogLevel.put(
+ LogData.LogCategory.L7VSD_SYSTEM_SOCKET, level);
+ else if (l7vsdLog.group(1).equals("l7vsd_system.signal"))
+ admData.l7vsdLogLevel.put(
+ LogData.LogCategory.L7VSD_SYSTEM_SIGNAL, level);
+ else if (l7vsdLog.group(1).equals("l7vsd_environment"))
+ admData.l7vsdLogLevel.put(
+ LogData.LogCategory.L7VSD_ENVIRONMENT, level);
+ else if (l7vsdLog.group(1).equals("l7vsd_environment.parameter"))
+ admData.l7vsdLogLevel.put(
+ LogData.LogCategory.L7VSD_ENVIRONMENT_PARAMETER, level);
+ else if (l7vsdLog.group(1).equals("l7vsd_logger"))
+ admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_LOGGER,
+ level);
+ else if (l7vsdLog.group(1).equals("l7vsd_parameter"))
+ admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_PARAMETER,
+ level);
+ else if (l7vsdLog.group(1).equals("l7vsd_event"))
+ admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_EVENT,
+ level);
+ else if (l7vsdLog.group(1).equals("l7vsd_schedule"))
+ admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_SCHEDULE,
+ level);
+ else if (l7vsdLog.group(1).equals("l7vsd_program"))
+ admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_PROGRAM,
+ level);
+ else if (l7vsdLog.group(1).equals("l7vsd_protocol"))
+ admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_PROTOCOL,
+ level);
+ else if (l7vsdLog.group(1).equals("l7vsd_module"))
+ admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_MODULE,
+ level);
+ else if (l7vsdLog.group(1).equals("l7vsd_all"))
+ admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_ALL, level);
+ else {
+ ioCommandLogger.info("21093 Unknown log category: " + l7vsdLog.group(1));
+ continue;
+ }
+ }
+
+ // SNMP Agent log level regex
+ Pattern snmpLogLevel = Pattern.compile(
+ "^(snmpagent_\\w+)\\s+(debug|info|warn|error|fatal)$",
+ Pattern.MULTILINE);
+ Matcher snmpLog = snmpLogLevel.matcher(result);
+ while (snmpLog.find()) {
+ LogData.LogLevel level;
+ if (snmpLog.group(2).equals("debug"))
+ level = LogData.LogLevel.DEBUG;
+ else if (snmpLog.group(2).equals("info"))
+ level = LogData.LogLevel.INFO;
+ else if (snmpLog.group(2).equals("warn"))
+ level = LogData.LogLevel.WARN;
+ else if (snmpLog.group(2).equals("error"))
+ level = LogData.LogLevel.ERROR;
+ else if (snmpLog.group(2).equals("fatal"))
+ level = LogData.LogLevel.FATAL;
+ else {
+ ioCommandLogger.info("21094 Unknown log level: " + snmpLog.group(2));
+ continue;
+ }
+
+ if (snmpLog.group(1).equals("snmpagent_start_stop"))
+ admData.snmpLogLevel.put(
+ LogData.LogCategory.SNMPAGENT_START_STOP, level);
+ else if (snmpLog.group(1).equals("snmpagent_manager_receive"))
+ admData.snmpLogLevel.put(
+ LogData.LogCategory.SNMPAGENT_MANAGER_RECEIVE, level);
+ else if (snmpLog.group(1).equals("snmpagent_manager_send"))
+ admData.snmpLogLevel.put(
+ LogData.LogCategory.SNMPAGENT_MANAGER_SEND, level);
+ else if (snmpLog.group(1).equals("snmpagent_l7vsd_receive"))
+ admData.snmpLogLevel.put(
+ LogData.LogCategory.SNMPAGENT_L7VSD_RECEIVE, level);
+ else if (snmpLog.group(1).equals("snmpagent_l7vsd_send"))
+ admData.snmpLogLevel.put(
+ LogData.LogCategory.SNMPAGENT_L7VSD_SEND, level);
+ else if (snmpLog.group(1).equals("snmpagent_logger"))
+ admData.snmpLogLevel.put(LogData.LogCategory.SNMPAGENT_LOGGER,
+ level);
+ else if (snmpLog.group(1).equals("snmpagent_parameter"))
+ admData.snmpLogLevel.put(
+ LogData.LogCategory.SNMPAGENT_PARAMETER, level);
+ else if (snmpLog.group(1).equals("snmpagent_all"))
+ admData.snmpLogLevel.put(LogData.LogCategory.SNMPAGENT_ALL,
+ level);
+ else {
+ ioCommandLogger.info("21095 Unknown log level: " + snmpLog.group(1));
+ continue;
+ }
+ }
+
+ // Replication mode regex
+ Pattern replicationMode = Pattern.compile(
+ "^Replication Mode:\\s+(\\w+)", Pattern.MULTILINE);
+ Matcher rep = replicationMode.matcher(result);
+ if (rep.find()) {
+ if (rep.group(1).equals("MASTER"))
+ admData.replicationMode = ReplicationStatus.MASTER;
+ else if (rep.group(1).equals("MASTER_STOP"))
+ admData.replicationMode = ReplicationStatus.MASTER_STOP;
+ else if (rep.group(1).equals("SLAVE"))
+ admData.replicationMode = ReplicationStatus.SLAVE;
+ else if (rep.group(1).equals("SLAVE_STOP"))
+ admData.replicationMode = ReplicationStatus.SLAVE_STOP;
+ else if (rep.group(1).equals("SINGLE"))
+ admData.replicationMode = ReplicationStatus.SINGLE;
+ else if (rep.group(1).equals("OUT"))
+ admData.replicationMode = ReplicationStatus.OUT;
+ else {
+ ioCommandLogger.info("21096 Unknown replication status: " + rep.group(1));
+ }
+ }
+
+ // SNMP Agent connection status regex
+ Pattern snmpStatus = Pattern.compile(
+ "^SNMPAgent Connection Status:\\s+([-\\w]+)", Pattern.MULTILINE);
+ Matcher snmp = snmpStatus.matcher(result);
+ if (snmp.find()) {
+ if (snmp.group(1).equals("connecting"))
+ admData.snmpStatus = SnmpAgentStatus.CONNECTING;
+ else if (snmp.group(1).equals("non-connecting"))
+ admData.snmpStatus = SnmpAgentStatus.NON_CONNECTING;
+ else {
+ ioCommandLogger.info("21097 Unknown SNMP Agent status: " + snmp.group(1));
+ }
+ }
+
+ VirtualSetting vs = null;
+
+ // Virtual service regex
+ String virtualLine = "TCP (\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}):(\\d{1,5}) (\\w+) "
+ + "(\\w+) (0|1) (.*)\\s+([^\\s]+) (\\d+) (0|1)\\s+(\\d+) (\\d+) (\\d+)\\s*";
+ // Real server regex
+ String realLine = "\\s+-> (\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}):(\\d{1,5})\\s+Masq\\s+"
+ + "(\\d+)\\s+(\\d+)\\s+(\\d+)\\s*";
+
+ Pattern virtualService = Pattern.compile("^(?:" + virtualLine + "|"
+ + realLine + ")$", Pattern.MULTILINE);
+ Matcher virtual = virtualService.matcher(result);
+ while (virtual.find()) {
+
+ if (virtual.group(1) != null) { // virtual service line found
+ if (vs != null)
+ admData.virtualSettings.add(vs);
+ vs = new VirtualSetting();
+
+ vs.virtual = new EndPoint(virtual.group(1), virtual.group(2));
+ vs.protomod = virtual.group(3);
+ vs.sched = virtual.group(4);
+ vs.reschedule = virtual.group(5).equals("0") ? false : true;
+ vs.option = virtual.group(6);
+ String[] sorry = virtual.group(7).split(":");
+ if (sorry.length == 2 && sorry[1] != null) {
+ vs.sorryserver = new EndPoint(sorry[0], sorry[1]);
+ }
+ vs.maxconn = Integer.parseInt(virtual.group(8));
+ vs.sorryflag = virtual.group(9).equals("0") ? false : true;
+ vs.qosservice = Long.parseLong(virtual.group(10));
+ vs.qosclient = Long.parseLong(virtual.group(11));
+ vs.throughput = Long.parseLong(virtual.group(12));
+ } else { // real server line found
+ if (vs.real == null)
+ vs.real = new Vector<EndPoint>();
+ vs.real.add(new EndPoint(virtual.group(13), virtual.group(14), Integer.parseInt(virtual
+ .group(15)), Long.parseLong(virtual.group(16)), Long
+ .parseLong(virtual.group(17))));
+ }
+ }
+ if (vs != null)
+ admData.virtualSettings.add(vs);
+
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11535 L7vsAdmController::getData() out return=" + admData);
+ }
+ // --- debug log (out method) ---
+ return admData;
+ }
+ }
+
+ /**
+ *
+ * <p>
+ * setReplicationMode method
+ * </p>
+ *
+ * @param mode
+ * @return result of l7vsadm change replication mode command.
+ */
+ public boolean setReplicationMode(ReplicationStatus mode) {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7vsAdmController::setReplicationMode(ReplicationStatus mode) in ");
+ buf.append("mode=" + mode);
+ ioCommandLogger.debug("11536 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ synchronized (this) {
+ if (mode == null) {
+ ioCommandLogger.error("41228 Invalid replication status: " + mode);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11537 L7vsAdmController::setReplicationMode(ReplicationStatus mode) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ String command = l7vsadm + " -R -s ";
+ switch (mode) {
+ case MASTER:
+ case SLAVE:
+ command += "start";
+ break;
+ case MASTER_STOP:
+ case SLAVE_STOP:
+ command += "stop";
+ break;
+ default:
+ ioCommandLogger.error("41229 Invalid replication status: " + mode);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11538 L7vsAdmController::setReplicationMode(ReplicationStatus mode) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ String result = runProcess(command);
+ if (result == null || result.length() != 0) {
+ ioCommandLogger.error("41230 Command error: command=" + command);
+ ioCommandLogger.error("41231 Command error: result=" + result);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11539 L7vsAdmController::setReplicationMode(ReplicationStatus mode) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11540 L7vsAdmController::setReplicationMode(ReplicationStatus mode) out return=true");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+ }
+
+ /**
+ *
+ * <p>
+ * setLogLevel method
+ * </p>
+ *
+ * @param category
+ * @return result of l7vsadm set log level command.
+ */
+ public boolean setLogLevel(HashMap<LogData.LogCategory, LogData.LogLevel> category) {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7vsAdmController::setLogLevel(HashMap<LogData.LogCategory, LogData.LogLevel> category) in ");
+ buf.append("category=" + category);
+ ioCommandLogger.debug("11541 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ synchronized (this) {
+ if (category == null) {
+ ioCommandLogger.error("41232 Invalid log category map: " + category);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11542 L7vsAdmController::setLogLevel(HashMap<LogData.LogCategory, LogData.LogLevel> category) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ Iterator<LogData.LogCategory> keys = category.keySet().iterator();
+ while (keys.hasNext()) {
+ String command = l7vsadm;
+ LogData.LogCategory c = (LogData.LogCategory) keys.next();
+ switch (c) {
+ case L7VSD_NETWORK:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_network";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_NETWORK_BANDWIDTH:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_network.bandwidth";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_NETWORK_NUM_CONNECTION:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_network.num_connection";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_NETWORK_QOS:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_network.qos";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_VIRTUAL_SERVICE:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_virtual_service";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_REAL_SERVER:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_real_server";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_SORRY_SERVER:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_sorry_server";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_REAL_SERVER_BALANCING:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_real_server.balancing";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_REPLICATION:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_replication";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_START_STOP:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_start_stop";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_SYSTEM:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_system";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_SYSTEM_MEMORY:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_system.memory";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_SYSTEM_SOCKET:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_system.socket";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_SYSTEM_SIGNAL:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_system.signal";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_ENVIRONMENT:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_environment";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_ENVIRONMENT_PARAMETER:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_environment.parameter";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_LOGGER:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_logger";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_PARAMETER:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_parameter";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_EVENT:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_event";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_SCHEDULE:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_schedule";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_PROGRAM:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_program";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_PROTOCOL:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_protocol";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_MODULE:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c l7vsd_module";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case L7VSD_ALL:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -L -c all";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case SNMPAGENT_START_STOP:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -S -c snmpagent_start_stop";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case SNMPAGENT_MANAGER_RECEIVE:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -S -c snmpagent_manager_receive";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case SNMPAGENT_MANAGER_SEND:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -S -c snmpagent_manager_send";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case SNMPAGENT_L7VSD_RECEIVE:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -S -c snmpagent_l7vsd_receive";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case SNMPAGENT_L7VSD_SEND:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -S -c snmpagent_l7vsd_send";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case SNMPAGENT_LOGGER:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -S -c snmpagent_logger";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case SNMPAGENT_PARAMETER:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -S -c snmpagent_parameter";
+ break;
+ default:
+ continue;
+ }
+ break;
+ case SNMPAGENT_ALL:
+ switch (category.get(c)) {
+ case DEBUG:
+ case INFO:
+ case WARN:
+ case ERROR:
+ case FATAL:
+ command += " -S -c all";
+ break;
+ default:
+ continue;
+ }
+ break;
+ default:
+ ioCommandLogger.info("21098 Unknown log category: " + c);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11543 L7vsAdmController::setLogLevel(HashMap<LogData.LogCategory, LogData.LogLevel> category) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ switch (category.get(c)) {
+ case DEBUG:
+ command += " -l debug";
+ break;
+ case INFO:
+ command += " -l info";
+ break;
+ case WARN:
+ command += " -l warn";
+ break;
+ case ERROR:
+ command += " -l error";
+ break;
+ case FATAL:
+ command += " -l fatal";
+ break;
+ default:
+ ioCommandLogger.info("21099 Unknown log level: " + category.get(c));
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11544 L7vsAdmController::setLogLevel(HashMap<LogData.LogCategory, LogData.LogLevel> category) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ String result = runProcess(command);
+ if (result == null || result.length() != 0) {
+ ioCommandLogger.error("41233 Command error: command=" + command);
+ ioCommandLogger.error("41234 Command error: result=" + result);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11545 L7vsAdmController::setLogLevel(HashMap<LogData.LogCategory, LogData.LogLevel> category) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+ }
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11546 L7vsAdmController::setLogLevel(HashMap<LogData.LogCategory, LogData.LogLevel> category) out return=true");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+ }
+
+ /**
+ *
+ * <p>
+ * dumpReplicationData method
+ * </p>
+ *
+ * @return result of l7vsadm replication dump command.
+ */
+ public boolean dumpReplicationData() {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11547 L7vsAdmController::dumpReplicationData() in");
+ }
+ // --- debug log (in method) ---
+
+ synchronized (this) {
+ String command = l7vsadm + " -R -d";
+ String result = runProcess(command);
+ if (result == null || result.length() != 0) {
+ ioCommandLogger.error("41235 Command error: command=" + command);
+ ioCommandLogger.error("41236 Command error: result=" + result);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11548 L7vsAdmController::dumpReplicationData() out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11549 L7vsAdmController::dumpReplicationData() out return=true");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+ }
+
+ /**
+ *
+ * <p>
+ * reloadConf method
+ * </p>
+ *
+ * @param c
+ * @return result of l7vsadm reload config command.
+ */
+ public boolean reloadConf(L7vsConfCategory c) {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7vsAdmController::reloadConf(L7vsConfCategory c) in ");
+ buf.append("c=" + c);
+ ioCommandLogger.debug("11550 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ synchronized (this) {
+ if (c == null) {
+ ioCommandLogger.error("41237 Invalid argument: " + c);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11551 L7vsAdmController::reloadConf(L7vsConfCategory c) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ String command = l7vsadm + " -P -r ";
+ switch (c) {
+ case ALL:
+ command += "all";
+ break;
+ case L7VSD:
+ command += "l7vsd";
+ break;
+ case IOMUX:
+ command += "iomux";
+ break;
+ case LSOCK:
+ command += "lsock";
+ break;
+ case CONN:
+ command += "conn";
+ break;
+ case DEST:
+ command += "dest";
+ break;
+ case SERVICE:
+ command += "service";
+ break;
+ case MODULE:
+ command += "module";
+ break;
+ case REPLICATION:
+ command += "replication";
+ break;
+ case LOGGER:
+ command += "logger";
+ break;
+ case L7VSADM:
+ command += "l7vsadm";
+ break;
+ case SNMPAGENT:
+ command += "snmpagent";
+ break;
+ default:
+ ioCommandLogger.error("41238 Unknown log category: " + c);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11552 L7vsAdmController::reloadConf(L7vsConfCategory c) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ String result = runProcess(command);
+ if (result == null || result.length() != 0) {
+ ioCommandLogger.error("41239 Command error: command=" + command);
+ ioCommandLogger.error("41240 Command error: result=" + result);
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11553 L7vsAdmController::reloadConf(L7vsConfCategory c) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11554 L7vsAdmController::reloadConf(L7vsConfCategory c) out return=true");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+ }
+
+ /**
+ *
+ * <p>
+ * runProcess method
+ * </p>
+ *
+ * @param command
+ * @return result string of command execution
+ */
+ protected String runProcess(String command) {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7vsAdmController::runProcess(String command) in ");
+ buf.append("command=\"" + command + "\"");
+ ioCommandLogger.debug("11555 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ synchronized (this) {
+ StringBuffer result = new StringBuffer();
+
+ try {
+ // TODO using sudo command temporally
+ Process ps = Runtime.getRuntime().exec("sudo " + command);
+ InputStream stderr = ps.getErrorStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(stderr));
+ String line = null;
+ while ((line = br.readLine()) != null) {
+ result.append(line + "\n");
+ }
+ InputStream stdout = ps.getInputStream();
+ br = new BufferedReader(new InputStreamReader(stdout));
+ while ((line = br.readLine()) != null) {
+ result.append(line + "\n");
+ }
+
+ Pattern p = Pattern
+ .compile("^COMMON ERROR.*timeout");
+ Matcher m = p.matcher(result);
+ if (m.find()) {
+ Parameter param = Parameter.getInstance();
+ param.setValue(Parameter.L7VSADM_TIMEOUT_FLAG, "yes");
+ } else {
+ Parameter param = Parameter.getInstance();
+ param.setValue(Parameter.L7VSADM_TIMEOUT_FLAG, null);
+ }
+ } catch (Exception e) {
+ ioCommandLogger.error("41241 Exception occured: " + e.getMessage());
+ result = null;
+ }
+
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11556 L7vsAdmController::runProcess(String command) out return=" + result);
+ }
+ // --- debug log (out method) ---
+ return (result == null) ? null : result.toString();
+ }
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+import java.util.*;
+import java.io.Serializable;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.LogCategorySet;
+
+/**
+ *
+ * <p>class L7vsAdmData</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tanuma
+ */
+public class L7vsAdmData extends VirtualSetting implements Serializable {
+ static final long serialVersionUID = 1L;
+
+ /**
+ * Virtual service setting.
+ */
+ public Vector<VirtualSetting> virtualSettings;
+
+ /**
+ * Replication status. (MASTER, MASTER_STOP, SLAVE, SLAVE_STOP, SINGLE, OUT)
+ */
+ public ReplicationStatus replicationMode;
+
+ /**
+ * SNMP Agent status. (CONNECTING, NON_CONNECTING)
+ */
+ public SnmpAgentStatus snmpStatus;
+
+ /**
+ * l7vsd log level
+ */
+ public HashMap<LogData.LogCategory, LogData.LogLevel> l7vsdLogLevel;
+
+ /**
+ * SNMP Agent log level
+ */
+ public HashMap<LogData.LogCategory, LogData.LogLevel> snmpLogLevel;
+
+ private Logger ioCommandLogger = Logger.getLogger(LogCategorySet.GUI_IO_COMMAND);
+
+ /**
+ *
+ * Constructor
+ *
+ */
+ public L7vsAdmData() {
+ // --- debug log (constructor) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11509 class L7vsAdmData created.");
+ }
+ // --- debug log (constructor) ---
+
+ this.virtualSettings = new Vector<VirtualSetting>();
+ this.l7vsdLogLevel = new HashMap<LogData.LogCategory, LogData.LogLevel>();
+ this.snmpLogLevel = new HashMap<LogData.LogCategory, LogData.LogLevel>();
+ this.replicationMode = ReplicationStatus.OUT;
+ this.snmpStatus = SnmpAgentStatus.NON_CONNECTING;
+ }
+
+ /**
+ *
+ * <p> equals method</p>
+ *
+ * @param admData
+ * @return Compares this L7vsAdmData to the specified object.
+ * The result is true if and only if the argument is not null
+ * and is a L7vsAdmData object that represents the same field as this object.
+ */
+ public boolean equals(L7vsAdmData admData) {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11510 L7vsAdmData::equals(L7vsAdmData admData) in admData=(" + admData + ")");
+ }
+ // --- debug log (in method) ---
+
+ if (admData != null &&
+ this.virtualSettings.equals(admData.virtualSettings) &&
+ this.replicationMode == admData.replicationMode &&
+ this.snmpStatus == admData.snmpStatus &&
+ this.l7vsdLogLevel.equals(admData.l7vsdLogLevel) &&
+ this.snmpLogLevel.equals(admData.snmpLogLevel)) {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11511 L7vsAdmData::equals(L7vsAdmData admData) out return=true");
+ }
+ // --- debug log (in method) ---
+ return true;
+ }
+
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11512 L7vsAdmData::equals(L7vsAdmData admData) out return=false");
+ }
+ // --- debug log (in method) ---
+ return false;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public String toString() {
+ return
+ "virtualSettings=" + this.virtualSettings + ", " +
+ "replicationMode=" + this.replicationMode + ", " +
+ "snmpLogLevel=" + this.snmpLogLevel + ", " +
+ "l7vsdLogLevel=" + this.l7vsdLogLevel + ", " +
+ "snmpLogLevel=" + this.snmpLogLevel;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+/**
+ * <p>class L7vsConfCategory</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tanuma
+ */
+public enum L7vsConfCategory {
+ ALL,
+ L7VSD,
+ IOMUX,
+ LSOCK,
+ CONN,
+ DEST,
+ SERVICE,
+ MODULE,
+ REPLICATION,
+ LOGGER,
+ L7VSADM,
+ SNMPAGENT
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+/**
+ * l7vs config file controller,
+ * Confing file reader and writer.
+ * <p>class L7vsConfController</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author nakai.
+ */
+
+public class L7vsConfController {
+
+ /**
+ * l7vs config file position and name.
+ */
+ protected static String FILENAME = "/etc/l7vs/l7vs.cf";
+
+ protected static String LOGGER_MASTER_KEY = "logger";
+
+ protected static String L7VSADM_MASTER_KEY = "l7vsadm";
+
+ protected static String REPLICATION_MASTER_KEY = "replication";
+
+ protected static String SNMPAGENT_MASTER_KEY = "snmpagent";
+
+ /**
+ * l7vsd log File Name key
+ */
+ protected static String LB_LOG_FILENAME_KEY = "l7vsd_log_filename";
+
+ /**
+ * l7vsd log rotate key
+ */
+ protected static String LB_LOG_ROTATION_KEY = "l7vsd_rotation";
+
+ /**
+ * l7vsd log max backup index key
+ */
+ protected static String LB_LOG_MAXBACKUPINDEX_KEY = "l7vsd_max_backup_index";
+
+ /**
+ * l7vsd log rotate timing key
+ */
+ protected static String LB_LOG_ROTATE_TIMING_KEY = "l7vsd_rotation_timing";
+
+ /**
+ * l7vsd log rotate timing type key
+ */
+ protected static String LB_LOG_ROTATE_TIMING_VALUE_KEY = "l7vsd_rotation_timing_value";
+
+ /**
+ * l7vsd log file size max value key
+ */
+ protected static String LB_LOG_MAXFILESIZE_KEY = "l7vsd_max_filesize";
+
+ /**
+ * l7vsd log level for network category key
+ */
+ protected static String LB_LOGCATEGORY_NETWORK_KEY = "l7vsd_network";
+
+ /**
+ * l7vsd log level for network.bandwidth category key
+ */
+ protected static String LB_LOGCATEGORY_NETWORK_BANDWIDTH_KEY = "l7vsd_network.bandwidth";
+
+ /**
+ * k7vsd log level for network.connection category key
+ */
+ protected static String LB_LOGCATEGORY_NETWORK_NUM_CONNECTION_KEY = "l7vsd_network.num_connection";
+
+ /**
+ * l7vsd log level for network qos category key
+ */
+ protected static String LB_LOGCATEGORY_NETWORK_QOS_KEY = "l7vsd_network.qos";
+
+ /**
+ * l7vsd log level for virtual service category key
+ */
+ protected static String LB_LOGCATEGORY_VIRTUALSERVICE_KEY = "l7vsd_virtual_service";
+
+ /**
+ * l7vsd log level for real server category key
+ */
+ protected static String LB_LOGCATEOGRY_REALSERVER_KEY = "l7vsd_real_server";
+
+ /**
+ * l7vsd log level for sorry server category key
+ */
+ protected static String LB_LOGCATEOGRY_SORRYSERVER_KEY = "l7vsd_sorry_server";
+
+ /**
+ * l7vsd log level for realserver balancing category key
+ */
+ protected static String LB_LOGCATEOGRY_REALSERVER_BALANCING_KEY = "l7vsd_real_server.balancing";
+
+ /**
+ * l7vsd log level for replication category key
+ */
+ protected static String LB_LOGCATEOGRY_REPLICATION_KEY = "l7vsd_replication";
+
+ /**
+ * l7vsd log level for start and stop messege category key
+ */
+ protected static String LB_LOGCATEOGRY_STARTSTOP_KEY = "l7vsd_start_stop";
+
+ /**
+ * l7vsd log level for system category key
+ */
+ protected static String LB_LOGCATEOGRY_SYSTEM_KEY = "l7vsd_system";
+
+ /**
+ * l7vsd log level for memory in system category key
+ */
+ protected static String LB_LOGCATEOGRY_SYSTEMMEMORY_KEY = "l7vsd_system.memory";
+
+ /**
+ * l7vsd log level for socket category key
+ */
+ protected static String LB_LOGCATEOGRY_SYSTEMSOCKET_KEY = "l7vsd_system.socket";
+
+ /**
+ * l7vsd log level for signal category key
+ */
+ protected static String LB_LOGCATEOGRY_SYSTEMSIGNAL_KEY = "l7vsd_system.signal";
+
+ /**
+ * l7vsd log level for environment key
+ */
+ protected static String LB_LOGCATEOGRY_ENVIROMENT_KEY = "l7vsd_environment";
+
+ /**
+ * l7vsd log level for environment parameter category key
+ */
+ protected static String LB_LOGCATEOGRY_ENVIROMENTPARAMTER_KEY = "l7vsd_environment.parameter";
+
+ /**
+ * l7vsd log level for logger category key
+ */
+ protected static String LB_LOGCATEGORY_LOGGER_KEY = "l7vsd_logger";
+
+ /**
+ * l7vsd log level for parameter category key
+ */
+ protected static String LB_LOGCATEGORY_PARAMTER = "l7vsd_parameter";
+
+ /**
+ * l7vsd log level for event category key
+ */
+ protected static String LB_LOGCATEGORY_EVENT_KEY = "l7vsd_event";
+
+ /**
+ * l7vsd log level for schedule category key
+ */
+ protected static String LB_LOGCATEGORY_SCHEDULE_KEY = "l7vsd_schedule";
+
+ /**
+ * l7vsd log level for program category key
+ */
+ protected static String LB_LOGCATEGORY_PROGRAM_KEY = "l7vsd_program";
+
+ /**
+ * l7vsd log level for protocol category key
+ */
+ protected static String LB_LOGCATEGORY_PROTOCOL_KEY = "l7vsd_protocol";
+
+ /**
+ * l7vsd log level for module category key
+ */
+ protected static String LB_LOGCATEGORY_MODULE_KEY = "l7vsd_module";
+
+ /**
+ * l7vsadm log file name key
+ */
+ protected static String ADM_LOG_FILENAME_KEY = "l7vsadm_log_filename";
+
+ /**
+ * l7vsadm log rotation key
+ */
+ protected static String ADM_LOG_ROTATION_KEY = "l7vsadm_rotation";
+
+ /**
+ * l7vsadm log maxbackup indexn key
+ */
+ protected static String ADM_LOG_MAXBACKUPINDEX_KEY = "l7vsadm_max_backup_index";
+
+ /**
+ * l7vsadm log rotate timing key
+ */
+ protected static String ADM_LOG_ROTATE_TIMING_KEY = "l7vsadm_rotation_timing";
+
+ /**
+ * l7vsadm log rotate timing
+ */
+ protected static String ADM_LOG_ROTATE_TIMING_VALUE_KEY = "l7vsadm_rotation_timing_value";
+
+ /**
+ * l7vsadm log maxfilesize key
+ */
+ protected static String ADM_LOG_MAXFILESIZE_KEY = "l7vsadd_max_filesize";
+
+ /**
+ * l7vsadm log level for pase key
+ */
+ protected static String ADM_LOGCATEGORY_PARSE_KEY = "l7vsadm_parse";
+
+ /**
+ * l7vsadm log level for operate key
+ */
+ protected static String ADM_LOGCATEGORY_OPERATE_KEY = "l7vsadm_operate";
+
+ /**
+ * l7vsadm log level for communicate key
+ */
+ protected static String ADM_LOGCATEGORY_COMMUNICATE_KEY = "l7vsadm_communicate";
+
+ /**
+ * l7vsadm log level for config result key
+ */
+ protected static String ADM_LOGCATEGORY_CONFIG_RESULT_KEY = "l7vsadm_config_result";
+
+ /**
+ * l7vsadm log level for common key
+ */
+ protected static String ADM_LOGCATEOGRY_COMMON = "l7vsadm_common";
+
+ /**
+ * l7vsadm logl level for logger key
+ */
+ protected static String ADM_LOGCATEGORY_LOGGER = "l7vsadm_logger";
+
+ /**
+ * l7vsadm log level for parameter key
+ */
+ protected static String ADM_LOGCATEGORY_PARAMETER = "l7vsadm_parameter";
+
+ /**
+ * l7vsadm log level for protocol key
+ */
+ protected static String ADM_LOGCATEOGRY_PROTOCOL = "l7vsadm_protocol";
+
+ /**
+ * l7vsadm log level for module key
+ */
+ protected static String ADM_LOGCATEOGRY_MODULE = "l7vsadm_module";
+
+ /**
+ * snmp log filename kay
+ */
+ protected static String SNMP_LOG_FILENAME_KEY = "snmpagent_log_filename";
+
+ /**
+ * snmp log rotatetion key
+ */
+ protected static String SNMP_LOG_ROTATION_KEY = "snmpagent_rotation";
+
+ /**
+ * snmp max backup num key
+ */
+ protected static String SNMP_LOG_MAXBACKUPINDEX_KEY = "snmpagent_max_backup_index";
+
+ /**
+ * snmp log rotate timing key
+ */
+ protected static String SNMP_LOG_ROTATE_TIMING_KEY = "snmpagent_rotation_timing";
+
+ /**
+ * snmp log rotate timing value key
+ */
+ protected static String SNMP_LOG_ROTATE_TIMING_VALUE_KEY = "snmpagent_rotation_timing_value";
+
+ /**
+ * snmp log max filesize key
+ */
+ protected static String SNMP_MAX_FILESIZE_KEY = "snmpagent_max_filesize";
+
+ /**
+ * snmp log level for start stop message category key
+ */
+ protected static String SNMP_LOGCATEOGRY_STARTSTOP_KEY = "snmpagent_start_stop";
+
+ /**
+ * snmp log level for manager recive category key
+ */
+ protected static String SNMP_LOGCATEGORY_MANAGER_RECEIVE_KEY = "snmpagent_manager_receive";
+
+ /**
+ * snmp log level for manager send category key
+ */
+ protected static String SNMP_LOGCATEGORY_MANAGER_SEND_KEY = "snmpagent_manager_send";
+
+ /**
+ * snmp log level for l7vsd recive category key
+ */
+ protected static String SNMP_LOGCATEGORY_L7VSD_RECEIVE_KEY = "snmpagent_l7vsd_receive";
+
+ /**
+ * snmp log level for l7vsd send category key
+ */
+ protected static String SNMP_LOGCATEGORY_L7VSD_SEND_KEY = "snmpagent_l7vsd_send";
+
+ /**
+ * snmp log level for logger category key
+ */
+ protected static String SNMP_LOGCATEGORY_LOGGER = "snmpagent_logger";
+
+ /**
+ * snmp log level for parameter category key
+ */
+ protected static String SNMP_LOGCATEGORY_PARAMETER = "snmpagent_parameter";
+
+ /**
+ * l7vsadm command interval key
+ */
+ protected static String ADM_CMD_INTERVAL_KEY = "cmd_interval";
+
+ /**
+ * l7vsadm command retry count key
+ */
+ protected static String ADM_CMD_COUNT_KEY = "cmd_count";
+
+ /**
+ * l7vsadm connection retry interval timing key
+ */
+ protected static String ADM_CON_INTERVAL_KEY = "con_interval";
+
+ /**
+ * l7vsadm connection retry count key
+ */
+ protected static String ADM_CON_COUNT_KEY = "con_count";
+
+ /**
+ * l7vsd replication target ipaddress key
+ */
+ protected static String REPLICATION_IPADDR_KEY = "ip_addr";
+
+ /**
+ * l7vsd replication using portno key
+ */
+ protected static String REPLICATION_SERVICENAME_KEY = "service_name";
+
+ /**
+ * l7vsd replication using NIC kay
+ */
+ protected static String REPLICATION_NIC_KEY = "nic";
+
+ /**
+ * l7vsd replication interval timing key
+ */
+ protected static String REPLICATION_INTERVAL_KEY = "interval";
+
+ /**
+ * l7vsd replication interval timing key
+ */
+ protected static String REPLICATION_COMPULSORILY_INTERVAL_KEY = "compulsorily_interval";
+
+ /**
+ * l7vsd replication component base key
+ */
+ protected static String REPLICATION_COMPONENT_ID_BASE_KEY = "cmponent_id_";
+
+ /**
+ * l7vsd replication component size base key
+ */
+ protected static String REPLICATION_COMPONENT_SIZE_BASE_KEY = "cmponent_size_";
+
+ /**
+ * SNMPAgent using NIC key
+ */
+ protected static String SNMPAGENT_NIC_KEY = "nic";
+
+ /**
+ * SNMPAgent using ipaddress key
+ */
+ protected static String SNMPAGENT_IPADDR_KEY = "ip_addr";
+
+ /**
+ * SNMPAgent using service port key
+ */
+ protected static String SNMPAGENT_PORT_KEY = "port";
+
+ /**
+ * SNMPAgent using interval key
+ */
+ protected static String SNMPAGENT_INTERVAL_KEY = "interval";
+
+ /**
+ * SNMPAgent using status key(this value is temp)
+ */
+ protected static String SNMPAGENT_STATUS_KEY = "status";
+
+ /**
+ * l7vsd replication using max component num
+ */
+ protected static int MAX_REPLICATION_COMPONENT_COUNT = 99;
+
+ /**
+ * pair class
+ * <p>class pair</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author kubota
+ */
+ protected class Pair<E, N> {
+ protected E elementFirst;
+
+ protected N elementSecond;
+
+ public Pair(E firstIn, N secondIn) {
+ elementFirst = firstIn;
+ elementSecond = secondIn;
+ }
+
+ public void set(E firstIn, N secondIn) {
+ elementFirst = firstIn;
+ elementSecond = secondIn;
+ }
+
+ public E first() {
+ return elementFirst;
+ }
+
+ public N second() {
+ return elementSecond;
+ }
+ }
+
+ protected Pair<String, String> paseKey(String inLine) {
+ if (inLine == null)
+ return null;
+ int pos = inLine.indexOf("=");
+ if (pos == -1)
+ return new Pair(inLine, "");
+ String first = inLine.substring(0, pos);
+ String second = inLine.substring(pos + 1, inLine.length());
+ if (first.indexOf('#') != -1)
+ return new Pair<String, String>("", "");
+ if (second.indexOf('#') != -1) {
+ pos = second.indexOf('#');
+ second = second.substring(0, pos);
+ }
+ first = first.trim();
+ second = second.trim();
+ if (second.matches("^\".*\"$"))
+ second = second.substring(1, second.length() - 1);
+ Pair<String, String> pair = new Pair<String, String>(first, second);
+ return pair;
+ }
+
+ /**
+ * component use set.
+ * <p>class ComponentSet</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author kubota
+ */
+ protected class ComponentSet {
+ public Pair<String, String> idPair;
+
+ public Pair<String, String> sizePair;
+ }
+
+ protected static LogData.LogLevel convStringToLogLevel(String instr)
+ throws org.ultramonkey.l7.model.FileNotReadException {
+ if (instr == null) {
+ org.ultramonkey.l7.model.FileNotReadException exception = new org.ultramonkey.l7.model.FileNotReadException();
+ exception
+ .setErrMessage("function L7vsConfController::convStringToLogLevel(String) param is null");
+ throw exception;
+ }
+ if (instr.equals("debug"))
+ return LogData.LogLevel.DEBUG;
+ else if (instr.equals("DEBUG"))
+ return LogData.LogLevel.DEBUG;
+ else if (instr.equals("error"))
+ return LogData.LogLevel.ERROR;
+ else if (instr.equals("ERROR"))
+ return LogData.LogLevel.ERROR;
+ else if (instr.equals("fatal"))
+ return LogData.LogLevel.FATAL;
+ else if (instr.equals("FATAL"))
+ return LogData.LogLevel.FATAL;
+ else if (instr.equals("info"))
+ return LogData.LogLevel.INFO;
+ else if (instr.equals("INFO"))
+ return LogData.LogLevel.INFO;
+ else if (instr.equals("warn"))
+ return LogData.LogLevel.WARN;
+ else if (instr.endsWith("WARN"))
+ return LogData.LogLevel.WARN;
+ org.ultramonkey.l7.model.FileNotReadException exception = new org.ultramonkey.l7.model.FileNotReadException();
+ exception.setErrMessage("");
+ throw exception;
+ }
+
+ protected static String convLogLevelToLogString(LogData.LogLevel inlevel) {
+ if (inlevel == LogData.LogLevel.DEBUG)
+ return "\"debug\"";
+ if (inlevel == LogData.LogLevel.ERROR)
+ return "\"error\"";
+ if (inlevel == LogData.LogLevel.FATAL)
+ return "\"fatal\"";
+ if (inlevel == LogData.LogLevel.INFO)
+ return "\"info\"";
+ if (inlevel == LogData.LogLevel.WARN)
+ return "\"warn\"";
+ return "";
+ }
+
+ // list to data for LoggerParameter.
+ protected void readLoggerParameter(L7vsConfData data,
+ java.util.LinkedList<String> inList)
+ throws org.ultramonkey.l7.model.FileNotReadException {
+ if (data == null || inList == null)
+ return;
+ for (java.util.Iterator<String> itr = inList.iterator(); itr.hasNext();) {
+ String buffer = itr.next();
+ Pair<String, String> pair = paseKey(buffer);
+ if (pair.first().equals(LB_LOG_FILENAME_KEY) )
+ data.logger.lbLog.fileName = pair.second();
+ else if (pair.first().equals(LB_LOG_ROTATION_KEY))
+ data.logger.lbLog.rotation = pair.second();
+ else if (pair.first().equals(LB_LOG_MAXBACKUPINDEX_KEY) ) {
+ try {
+ data.logger.lbLog.maxBackupIndex = Integer.parseInt(pair.second());
+ } catch (java.lang.NumberFormatException e) {
+ data.logger.lbLog.maxBackupIndex = 0;
+ }
+ }
+ else if (pair.first().equals(LB_LOG_ROTATE_TIMING_KEY))
+ data.logger.lbLog.rotationTiming = pair.second();
+ else if (pair.first().equals(LB_LOG_ROTATE_TIMING_VALUE_KEY))
+ data.logger.lbLog.rotationTimingValue = pair.second();
+ else if (pair.first().equals(LB_LOG_MAXFILESIZE_KEY))
+ data.logger.lbLog.maxFileSize = pair.second();
+ else if (pair.first().equals(LB_LOGCATEGORY_NETWORK_KEY) )
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_NETWORK,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEGORY_NETWORK_BANDWIDTH_KEY))
+ data.logger.lbLog.logLevel.put(
+ LogData.LogCategory.L7VSD_NETWORK_BANDWIDTH,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEGORY_NETWORK_NUM_CONNECTION_KEY))
+ data.logger.lbLog.logLevel.put(
+ LogData.LogCategory.L7VSD_NETWORK_NUM_CONNECTION,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEGORY_NETWORK_QOS_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_NETWORK_QOS,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEGORY_VIRTUALSERVICE_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_VIRTUAL_SERVICE,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEOGRY_REALSERVER_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_REAL_SERVER,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEOGRY_SORRYSERVER_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_SORRY_SERVER,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEOGRY_REALSERVER_BALANCING_KEY))
+ data.logger.lbLog.logLevel.put(
+ LogData.LogCategory.L7VSD_REAL_SERVER_BALANCING,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEOGRY_REPLICATION_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_REPLICATION,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEOGRY_STARTSTOP_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_START_STOP,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEOGRY_SYSTEM_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_SYSTEM,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEOGRY_SYSTEMMEMORY_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_SYSTEM_MEMORY,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEOGRY_SYSTEMSOCKET_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_SYSTEM_SOCKET,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEOGRY_SYSTEMSIGNAL_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_SYSTEM_SIGNAL,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEOGRY_ENVIROMENT_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_ENVIRONMENT,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEOGRY_ENVIROMENTPARAMTER_KEY))
+ data.logger.lbLog.logLevel.put(
+ LogData.LogCategory.L7VSD_ENVIRONMENT_PARAMETER,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEGORY_LOGGER_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_LOGGER,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEGORY_PARAMTER))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_PARAMETER,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEGORY_EVENT_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_EVENT,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEGORY_SCHEDULE_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_SCHEDULE,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEGORY_PROGRAM_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_PROGRAM,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEGORY_PROTOCOL_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_PROTOCOL,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(LB_LOGCATEGORY_MODULE_KEY))
+ data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_MODULE,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(ADM_LOG_FILENAME_KEY))
+ data.logger.admLog.fileName = pair.second();
+ else if (pair.first().equals(ADM_LOG_ROTATION_KEY))
+ data.logger.admLog.rotation = pair.second();
+ else if (pair.first().equals(ADM_LOG_MAXBACKUPINDEX_KEY)) {
+ try {
+ data.logger.admLog.maxBackupIndex = Integer.parseInt(pair.second());
+ } catch (java.lang.NumberFormatException e) {
+ data.logger.admLog.maxBackupIndex = 0;
+ }
+ } else if (pair.first().equals(ADM_LOG_ROTATE_TIMING_KEY))
+ data.logger.admLog.rotationTiming = pair.second();
+ else if (pair.first().equals(ADM_LOG_ROTATE_TIMING_VALUE_KEY))
+ data.logger.admLog.rotationTimingValue = pair.second();
+ else if (pair.first().equals(ADM_LOG_MAXFILESIZE_KEY))
+ data.logger.admLog.maxFileSize = pair.second();
+ else if (pair.first().equals(ADM_LOGCATEGORY_PARSE_KEY))
+ data.logger.admLog.logLevel.put(LogData.LogCategory.L7VSADM_PARSE,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(ADM_LOGCATEGORY_OPERATE_KEY))
+ data.logger.admLog.logLevel.put(LogData.LogCategory.L7VSADM_OPERATE,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(ADM_LOGCATEGORY_COMMUNICATE_KEY))
+ data.logger.admLog.logLevel.put(LogData.LogCategory.L7VSADM_COMMUNICATE,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(ADM_LOGCATEGORY_CONFIG_RESULT_KEY))
+ data.logger.admLog.logLevel.put(
+ LogData.LogCategory.L7VSADM_CONFIG_RESULT,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(ADM_LOGCATEOGRY_COMMON))
+ data.logger.admLog.logLevel.put(LogData.LogCategory.L7VSADM_COMMON,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(ADM_LOGCATEGORY_LOGGER))
+ data.logger.admLog.logLevel.put(LogData.LogCategory.L7VSADM_LOGGER,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(ADM_LOGCATEGORY_PARAMETER))
+ data.logger.admLog.logLevel.put(LogData.LogCategory.L7VSADM_PARAMETER,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(ADM_LOGCATEOGRY_PROTOCOL))
+ data.logger.admLog.logLevel.put(LogData.LogCategory.L7VSADM_PROTOCOL,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(ADM_LOGCATEOGRY_MODULE))
+ data.logger.admLog.logLevel.put(LogData.LogCategory.L7VSADM_MODULE,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(SNMP_LOG_FILENAME_KEY))
+ data.logger.snmpLog.fileName = pair.second();
+ else if (pair.first().equals(SNMP_LOG_ROTATION_KEY))
+ data.logger.snmpLog.rotation = pair.second();
+ else if (pair.first().equals(SNMP_LOG_MAXBACKUPINDEX_KEY)) {
+ try {
+ data.logger.snmpLog.maxBackupIndex = Integer.parseInt(pair.second());
+ } catch (java.lang.NumberFormatException e) {
+ data.logger.snmpLog.maxBackupIndex = 0;
+ }
+ } else if (pair.first().equals(SNMP_LOG_ROTATE_TIMING_KEY))
+ data.logger.snmpLog.rotationTiming = pair.second();
+ else if (pair.first().equals(SNMP_LOG_ROTATE_TIMING_VALUE_KEY))
+ data.logger.snmpLog.rotationTimingValue = pair.second();
+ else if (pair.first().equals(SNMP_MAX_FILESIZE_KEY))
+ data.logger.snmpLog.maxFileSize = pair.second();
+ else if (pair.first().equals(SNMP_LOGCATEOGRY_STARTSTOP_KEY))
+ data.logger.snmpLog.logLevel.put(
+ LogData.LogCategory.SNMPAGENT_START_STOP,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(SNMP_LOGCATEGORY_MANAGER_RECEIVE_KEY))
+ data.logger.snmpLog.logLevel.put(
+ LogData.LogCategory.SNMPAGENT_MANAGER_RECEIVE,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(SNMP_LOGCATEGORY_MANAGER_SEND_KEY))
+ data.logger.snmpLog.logLevel.put(
+ LogData.LogCategory.SNMPAGENT_MANAGER_SEND,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(SNMP_LOGCATEGORY_L7VSD_RECEIVE_KEY))
+ data.logger.snmpLog.logLevel.put(
+ LogData.LogCategory.SNMPAGENT_L7VSD_RECEIVE,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(SNMP_LOGCATEGORY_L7VSD_SEND_KEY))
+ data.logger.snmpLog.logLevel.put(
+ LogData.LogCategory.SNMPAGENT_L7VSD_SEND,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(SNMP_LOGCATEGORY_LOGGER))
+ data.logger.snmpLog.logLevel.put(LogData.LogCategory.SNMPAGENT_LOGGER,
+ convStringToLogLevel(pair.second()));
+ else if (pair.first().equals(SNMP_LOGCATEGORY_PARAMETER))
+ data.logger.snmpLog.logLevel.put(LogData.LogCategory.SNMPAGENT_PARAMETER,
+ convStringToLogLevel(pair.second()));
+ }
+ }
+
+ protected void readAdmParameter(L7vsConfData data, java.util.LinkedList<String> inList)
+ throws org.ultramonkey.l7.model.FileNotReadException {
+ if (data == null || inList == null)
+ return;
+ for (java.util.Iterator<String> itr = inList.iterator(); itr.hasNext();) {
+ String buffer = itr.next();
+ Pair<String, String> pair = paseKey(buffer);
+ if (pair.first().indexOf(ADM_CMD_INTERVAL_KEY) != -1) {
+ try {
+ data.admCmdInterval = Integer.parseInt(pair.second());
+ } catch (java.lang.NumberFormatException e) {
+ data.admCmdInterval = 0;
+ }
+ } else if (pair.first().indexOf(ADM_CMD_COUNT_KEY) != -1) {
+ try {
+ data.admCmdCount = Integer.parseInt(pair.second());
+ } catch (java.lang.NumberFormatException e) {
+ data.admCmdCount = 0;
+ }
+ } else if (pair.first().indexOf(ADM_CON_INTERVAL_KEY) != -1) {
+ try {
+ data.admConInterval = Integer.parseInt(pair.second());
+ } catch (java.lang.NumberFormatException e) {
+ data.admConInterval = 0;
+ }
+ } else if (pair.first().indexOf(ADM_CON_COUNT_KEY) != -1) {
+ try {
+ data.admConCount = Integer.parseInt(pair.second());
+ } catch (java.lang.NumberFormatException e) {
+ data.admConCount = 0;
+ }
+ }
+
+ }
+ }
+
+ protected void readSNMPAgentParameter(L7vsConfData data,
+ java.util.LinkedList<String> inList)
+ throws org.ultramonkey.l7.model.FileNotReadException {
+ if (data == null || inList == null)
+ return;
+ for (java.util.Iterator<String> itr = inList.iterator(); itr.hasNext();) {
+ String buffer = itr.next();
+ Pair<String, String> pair = paseKey(buffer);
+ if (pair.first().indexOf(SNMPAGENT_NIC_KEY) != -1)
+ data.snmpNIC = pair.second();
+ else if (pair.first().indexOf(SNMPAGENT_IPADDR_KEY) != -1)
+ data.snmpIpAddr = pair.second();
+ else if (pair.first().indexOf(SNMPAGENT_PORT_KEY) != -1)
+ data.snmpPort = pair.second();
+ else if (pair.first().indexOf(SNMPAGENT_INTERVAL_KEY) != -1) {
+ try {
+ data.snmpInterval = Integer.parseInt(pair.second());
+ } catch (java.lang.NumberFormatException e) {
+ data.snmpInterval = 0;
+ }
+ }
+ }
+ }
+
+ protected void readReplicationParameter(L7vsConfData data,
+ java.util.LinkedList<String> inList)
+ throws org.ultramonkey.l7.model.FileNotReadException {
+ if (data == null || inList == null)
+ return;
+ java.util.HashMap<String, Pair<String,String>> map = new java.util.HashMap<String, Pair<String,String>>();
+ for (java.util.Iterator<String> itr = inList.iterator(); itr.hasNext();) {
+ String buffer = itr.next();
+ Pair<String, String> pair = paseKey(buffer);
+ if (pair.first().indexOf(REPLICATION_IPADDR_KEY) != -1)
+ data.replicationOtherNode.host = pair.second();
+ else if (pair.first().indexOf(REPLICATION_SERVICENAME_KEY) != -1)
+ data.replicationOtherNode.port = pair.second();
+ else if (pair.first().indexOf(REPLICATION_NIC_KEY) != -1)
+ data.replicationNic = pair.second();
+ else if (pair.first().indexOf(REPLICATION_INTERVAL_KEY) != -1 &&
+ pair.first().indexOf(REPLICATION_COMPULSORILY_INTERVAL_KEY) == -1) {
+ try {
+ data.replicationInterval = Integer.parseInt(pair.second());
+ } catch (java.lang.NumberFormatException e) {
+ data.replicationInterval = 0;
+ }
+ } else if (pair.first().indexOf(REPLICATION_COMPONENT_ID_BASE_KEY) != -1) {
+ String number = pair.first().substring(REPLICATION_COMPONENT_ID_BASE_KEY.length(), REPLICATION_COMPONENT_ID_BASE_KEY.length() + 2);
+ Pair<String,String> tmpPair = map.get(number);
+ if( tmpPair == null )
+ map.put(number, new Pair<String,String>(pair.second(), "" ));
+ else
+ tmpPair.set(pair.first(), tmpPair.second());
+ } else if (pair.first().indexOf(REPLICATION_COMPONENT_SIZE_BASE_KEY) != -1) {
+ String number = pair.first().substring(REPLICATION_COMPONENT_SIZE_BASE_KEY.length(), REPLICATION_COMPONENT_SIZE_BASE_KEY.length() + 2);
+ Pair<String,String> tmpPair = map.get(number);
+ if( tmpPair == null )
+ map.put(number, new Pair<String,String>("", pair.second()));
+ else
+ tmpPair.set(tmpPair.first(), pair.second());
+ }
+ }
+ //data puts COMPONENTID and SIZE
+ data.component = new java.util.HashMap<String, Integer>();
+ for (java.util.Iterator<java.util.Map.Entry<String, Pair<String,String>>> itr = map.entrySet().iterator(); itr
+ .hasNext();) {
+ java.util.Map.Entry<String, Pair<String,String>> entry = itr.next();
+ Pair<String, String> pair = entry.getValue();
+ try {
+ data.component.put(pair.first(), Integer.parseInt(pair.second()));
+ } catch (java.lang.NumberFormatException e) {
+ data.component.put(pair.first(), 0);
+ }
+ }
+ }
+
+ /**
+ * l7vs.cf load function.
+ * @return L7vsConfData create from l7vs.cf file.
+ * @throws org.ultramonkey.l7/model.FileNotReadException
+ */
+ protected L7vsConfData loadFromFile()
+ throws org.ultramonkey.l7.model.FileNotReadException {
+
+ // data read on stack
+ java.util.Stack<String> stack = new java.util.Stack<String>();
+ try {
+ java.io.FileReader file = new java.io.FileReader(FILENAME);
+ java.io.BufferedReader reader = new java.io.BufferedReader(file);
+ String buffer;
+ while ((buffer = reader.readLine()) != null) {
+ if (buffer.length() != 0 && buffer.charAt(0) != '#') {
+ stack.push(buffer);
+ }
+ }
+ } catch (Exception e) {
+ org.ultramonkey.l7.model.FileNotReadException ex = new org.ultramonkey.l7.model.FileNotReadException();
+ ex.setErrMessage("Cannot read file : " + FILENAME + "/ base exception = "
+ + e.getMessage());
+ throw ex;
+ }
+ //category search.
+
+ L7vsConfData data = new L7vsConfData();
+ java.util.LinkedList<String> tmpList = new java.util.LinkedList<String>();
+ while (!stack.empty()) {
+ String buffer = stack.pop();
+ buffer = buffer.trim();
+ int pos = buffer.indexOf('#');
+ if( pos == 0 ) continue;
+ if( pos != -1 ) buffer = buffer.substring(0, pos);
+ else if (buffer.charAt(0) == '[' && buffer.charAt(buffer.length()-1) == ']') {
+ // select service;
+ if (buffer.indexOf(LOGGER_MASTER_KEY) != -1) {
+ readLoggerParameter(data, tmpList);
+ tmpList.clear();
+ continue;
+ } else if (buffer.indexOf(L7VSADM_MASTER_KEY) != -1) {
+ readAdmParameter(data, tmpList);
+ tmpList.clear();
+ continue;
+ } else if (buffer.indexOf(REPLICATION_MASTER_KEY) != -1) {
+ readReplicationParameter(data, tmpList);
+ tmpList.clear();
+ continue;
+ } else if (buffer.indexOf(SNMPAGENT_MASTER_KEY) != -1) {
+ readSNMPAgentParameter(data, tmpList);
+ tmpList.clear();
+ continue;
+ }
+ }
+ tmpList.addFirst(buffer);
+ }
+
+ return data;
+ }
+
+ private static String trimQuote(String s) {
+ if (s != null && s.matches("^\".*\"$")) {
+ s = s.substring(1, s.length() - 1);
+ }
+ return s;
+ }
+
+ protected void searchInsertData(String key, String value,
+ java.util.LinkedList<String> list, int start, int end) {
+ for (int i = start; i < end; ++i) {
+ String buffer = list.get(i).trim();
+ if (buffer.length() == 0)
+ continue;
+ int commentpos = buffer.indexOf("#");
+ if (commentpos != -1)
+ buffer = buffer.substring(commentpos, buffer.length());
+ Pair<String, String> pair = paseKey(buffer);
+ if (pair.first().length() == 0)
+ continue;
+ if (pair.first().equals(key)) {
+ if (pair.second().equals(trimQuote(value)))
+ return;
+ StringBuffer buf = new StringBuffer();
+ if (commentpos == -1)
+ buf.append('#');
+ buf.append(list.get(i));
+ list.remove(i);
+ list.add(i, buf.toString());
+ list.add(i + 1, key + "=" + value);
+ return;
+ }
+ }
+ list.add(end + 1, key + "=" + value);
+ }
+
+ /**
+ *
+ * <p> saveToFile method</p>
+ *
+ */
+ protected void saveToFile(L7vsConfData data)
+ throws org.ultramonkey.l7.model.FileNotWriteException {
+ java.util.LinkedList<String> datas = new java.util.LinkedList();
+ try {
+ java.io.FileReader file = new java.io.FileReader(FILENAME);
+ java.io.BufferedReader reader = new java.io.BufferedReader(file);
+ String buffer;
+ while ((buffer = reader.readLine()) != null) {
+ datas.addLast(buffer);
+ }
+ } catch (Exception e) {
+ org.ultramonkey.l7.model.FileNotWriteException ex = new org.ultramonkey.l7.model.FileNotWriteException();
+ ex.setErrMessage("Cannot open file : " + FILENAME);
+ throw ex;
+ }
+
+ //[logger]
+ int startpos = 0;
+ int endpos = 0; //logger value.
+ for (int i = 0; i < datas.size(); ++i) {
+ String buffer = datas.get(i).trim();
+ if (buffer.length() == 0)
+ continue;
+ if (buffer.charAt(0) == '#')
+ continue;
+ int cmntpos = buffer.indexOf("#");
+ if (cmntpos != -1)
+ buffer = buffer.substring(0, cmntpos).trim();
+ if (buffer.charAt(0) == '[' && buffer.charAt(buffer.length()-1) == ']') {
+ if (buffer.indexOf("logger") != -1 || buffer.indexOf("LOGGER") != -1) {
+ startpos = i + 1;
+ } else {
+ if (startpos != 0) {
+ endpos = i;
+ break;
+ }
+ }
+ }
+ }
+ if( endpos == 0 ) endpos = datas.size();
+ if (data.logger.lbLog.fileName != null
+ && data.logger.lbLog.fileName.length() != 0)
+ searchInsertData(LB_LOG_FILENAME_KEY,
+ "\"" + data.logger.lbLog.fileName + "\"", datas, startpos,
+ endpos);
+ if (data.logger.lbLog.rotation != null
+ && data.logger.lbLog.rotation.length() != 0)
+ searchInsertData(LB_LOG_ROTATION_KEY,
+ "\"" + data.logger.lbLog.rotation + "\"", datas, startpos,
+ endpos += 1);
+ if (data.logger.lbLog.maxBackupIndex != 0)
+ searchInsertData(LB_LOG_MAXBACKUPINDEX_KEY, String
+ .valueOf(data.logger.lbLog.maxBackupIndex), datas, startpos,
+ endpos += 1);
+ if (data.logger.lbLog.rotationTiming != null
+ && data.logger.lbLog.rotationTiming.length() != 0)
+ searchInsertData(LB_LOG_ROTATE_TIMING_KEY, "\""
+ + data.logger.lbLog.rotationTiming + "\"", datas, startpos,
+ endpos += 1);
+ if (data.logger.lbLog.rotationTimingValue != null
+ && data.logger.lbLog.rotationTimingValue.length() != 0)
+ searchInsertData(LB_LOG_ROTATE_TIMING_KEY, "\""
+ + data.logger.lbLog.rotationTimingValue + "\"", datas,
+ startpos, endpos += 1);
+ if (data.logger.lbLog.maxFileSize != null
+ && data.logger.lbLog.maxFileSize.length() != 0)
+ searchInsertData(LB_LOG_MAXFILESIZE_KEY, "\"" + data.logger.lbLog.maxFileSize
+ + "\"", datas, startpos, endpos += 1);
+ LogData.LogLevel level = data.logger.lbLog.logLevel
+ .get(LogData.LogCategory.L7VSD_NETWORK);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEGORY_NETWORK_KEY, buf, datas, startpos, endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel
+ .get(LogData.LogCategory.L7VSD_NETWORK_BANDWIDTH);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEGORY_NETWORK_BANDWIDTH_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel
+ .get(LogData.LogCategory.L7VSD_NETWORK_NUM_CONNECTION);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEGORY_NETWORK_NUM_CONNECTION_KEY, buf, datas,
+ startpos, endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_NETWORK_QOS);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEGORY_NETWORK_QOS_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_VIRTUAL_SERVICE);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEGORY_VIRTUALSERVICE_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_REAL_SERVER);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEOGRY_REALSERVER_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_SORRY_SERVER);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEOGRY_SORRYSERVER_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel
+ .get(LogData.LogCategory.L7VSD_REAL_SERVER_BALANCING);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEOGRY_REALSERVER_BALANCING_KEY, buf, datas,
+ startpos, endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_REPLICATION);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEOGRY_REPLICATION_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_START_STOP);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEOGRY_STARTSTOP_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_SYSTEM);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEOGRY_SYSTEM_KEY, buf, datas, startpos, endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_SYSTEM_MEMORY);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEOGRY_SYSTEMMEMORY_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_SYSTEM_SOCKET);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEOGRY_SYSTEMSOCKET_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_SYSTEM_SIGNAL);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEOGRY_SYSTEMSIGNAL_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_ENVIRONMENT);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEOGRY_ENVIROMENT_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel
+ .get(LogData.LogCategory.L7VSD_ENVIRONMENT_PARAMETER);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEOGRY_ENVIROMENTPARAMTER_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_LOGGER);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEGORY_LOGGER_KEY, buf, datas, startpos, endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_PARAMETER);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEGORY_PARAMTER, buf, datas, startpos, endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_SCHEDULE);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEGORY_SCHEDULE_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_EVENT);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEGORY_EVENT_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_PROGRAM);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEGORY_PROGRAM_KEY, buf, datas, startpos, endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_PROTOCOL);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEGORY_PROTOCOL_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_MODULE);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(LB_LOGCATEGORY_MODULE_KEY, buf, datas, startpos, endpos += 1);
+ }
+ }
+ if (data.logger.admLog.fileName != null
+ && data.logger.admLog.fileName.length() != 0)
+ searchInsertData(ADM_LOG_FILENAME_KEY, "\"" + data.logger.admLog.fileName
+ + "\"", datas, startpos, endpos += 1);
+ if (data.logger.admLog.rotation != null
+ && data.logger.admLog.rotation.length() != 0)
+ searchInsertData(ADM_LOG_ROTATION_KEY, "\"" + data.logger.admLog.rotation
+ + "\"", datas, startpos, endpos += 1);
+ if (data.logger.admLog.maxBackupIndex != 0)
+ searchInsertData(ADM_LOG_MAXBACKUPINDEX_KEY, String
+ .valueOf(data.logger.admLog.maxBackupIndex), datas, startpos,
+ endpos += 1);
+ if (data.logger.admLog.rotationTiming != null
+ && data.logger.admLog.rotationTiming.length() != 0)
+ searchInsertData(ADM_LOG_ROTATE_TIMING_KEY, "\""
+ + data.logger.admLog.rotationTiming + "\"", datas, startpos,
+ endpos += 1);
+ if (data.logger.admLog.rotationTimingValue != null
+ && data.logger.admLog.rotationTimingValue.length() != 0)
+ searchInsertData(ADM_LOG_ROTATE_TIMING_VALUE_KEY, "\""
+ + data.logger.admLog.rotationTimingValue + "\"", datas,
+ startpos, endpos += 1);
+ if (data.logger.admLog.maxFileSize != null
+ && data.logger.admLog.maxFileSize.length() != 0)
+ searchInsertData(ADM_LOG_MAXFILESIZE_KEY, "\""
+ + data.logger.admLog.maxFileSize + "\"", datas, startpos,
+ endpos += 1);
+ level = data.logger.admLog.logLevel.get(LogData.LogCategory.L7VSADM_PARSE);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(ADM_LOGCATEGORY_PARSE_KEY, buf, datas, startpos, endpos += 1);
+ }
+ }
+ level = data.logger.admLog.logLevel.get(LogData.LogCategory.L7VSADM_OPERATE);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(ADM_LOGCATEGORY_OPERATE_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.admLog.logLevel.get(LogData.LogCategory.L7VSADM_COMMUNICATE);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(ADM_LOGCATEGORY_COMMUNICATE_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.admLog.logLevel
+ .get(LogData.LogCategory.L7VSADM_CONFIG_RESULT);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(ADM_LOGCATEGORY_CONFIG_RESULT_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.admLog.logLevel.get(LogData.LogCategory.L7VSADM_COMMON);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(ADM_LOGCATEOGRY_COMMON, buf, datas, startpos, endpos += 1);
+ }
+ }
+ level = data.logger.admLog.logLevel.get(LogData.LogCategory.L7VSADM_LOGGER);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(ADM_LOGCATEGORY_LOGGER, buf, datas, startpos, endpos += 1);
+ }
+ }
+ level = data.logger.admLog.logLevel.get(LogData.LogCategory.L7VSADM_PARAMETER);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(ADM_LOGCATEGORY_PARAMETER, buf, datas, startpos, endpos += 1);
+ }
+ }
+ level = data.logger.admLog.logLevel.get(LogData.LogCategory.L7VSADM_PROTOCOL);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(ADM_LOGCATEOGRY_PROTOCOL, buf, datas, startpos, endpos += 1);
+ }
+ }
+ level = data.logger.admLog.logLevel.get(LogData.LogCategory.L7VSADM_MODULE);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(ADM_LOGCATEOGRY_MODULE, buf, datas, startpos, endpos += 1);
+ }
+ }
+ if (data.logger.snmpLog.fileName != null
+ && data.logger.snmpLog.fileName.length() != 0)
+ searchInsertData(SNMP_LOG_FILENAME_KEY, "\"" + data.logger.snmpLog.fileName
+ + "\"", datas, startpos, endpos += 1);
+ if (data.logger.snmpLog.rotation != null
+ && data.logger.snmpLog.rotation.length() != 0)
+ searchInsertData(SNMP_LOG_ROTATION_KEY, "\"" + data.logger.snmpLog.rotation
+ + "\"", datas, startpos, endpos += 1);
+ if (data.logger.snmpLog.maxBackupIndex != 0)
+ searchInsertData(SNMP_LOG_MAXBACKUPINDEX_KEY, String
+ .valueOf(data.logger.snmpLog.maxBackupIndex), datas,
+ startpos, endpos += 1);
+ if (data.logger.snmpLog.rotationTiming != null
+ && data.logger.snmpLog.rotationTiming.length() != 0)
+ searchInsertData(SNMP_LOG_ROTATE_TIMING_KEY, "\""
+ + data.logger.snmpLog.rotationTiming + "\"", datas,
+ startpos, endpos += 1);
+ if (data.logger.snmpLog.rotationTimingValue != null
+ && data.logger.snmpLog.rotationTimingValue.length() != 0)
+ searchInsertData(SNMP_LOG_ROTATE_TIMING_VALUE_KEY, "\""
+ + data.logger.snmpLog.rotationTimingValue + "\"", datas,
+ startpos, endpos += 1);
+ if (data.logger.snmpLog.maxFileSize != null
+ && data.logger.snmpLog.maxFileSize.length() != 0)
+ searchInsertData(SNMP_MAX_FILESIZE_KEY, "\"" + data.logger.snmpLog.maxFileSize
+ + "\"", datas, startpos, endpos += 1);
+ level = data.logger.snmpLog.logLevel
+ .get(LogData.LogCategory.SNMPAGENT_START_STOP);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(SNMP_LOGCATEOGRY_STARTSTOP_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.snmpLog.logLevel
+ .get(LogData.LogCategory.SNMPAGENT_MANAGER_RECEIVE);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(SNMP_LOGCATEGORY_MANAGER_RECEIVE_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.snmpLog.logLevel
+ .get(LogData.LogCategory.SNMPAGENT_MANAGER_SEND);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(SNMP_LOGCATEGORY_MANAGER_SEND_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.snmpLog.logLevel
+ .get(LogData.LogCategory.SNMPAGENT_L7VSD_RECEIVE);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(SNMP_LOGCATEGORY_L7VSD_RECEIVE_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.snmpLog.logLevel
+ .get(LogData.LogCategory.SNMPAGENT_L7VSD_SEND);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(SNMP_LOGCATEGORY_L7VSD_SEND_KEY, buf, datas, startpos,
+ endpos += 1);
+ }
+ }
+ level = data.logger.snmpLog.logLevel.get(LogData.LogCategory.SNMPAGENT_LOGGER);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(SNMP_LOGCATEGORY_LOGGER, buf, datas, startpos, endpos += 1);
+ }
+ }
+ level = data.logger.snmpLog.logLevel.get(LogData.LogCategory.SNMPAGENT_PARAMETER);
+ if (level != null) {
+ String buf = convLogLevelToLogString(level);
+ if (buf.length() != 0) {
+ searchInsertData(SNMP_LOGCATEGORY_PARAMETER, buf, datas, startpos, endpos += 1);
+ }
+ }
+
+ //
+ //[l7vsadm]
+ startpos = 0;
+ endpos = 0;
+ for (int i = 0; i < datas.size(); ++i) {
+ String buffer = datas.get(i).trim();
+ if (buffer.length() == 0)
+ continue;
+ if (buffer.charAt(0) == '#')
+ continue;
+ int cmntpos = buffer.indexOf("#");
+ if (cmntpos != -1)
+ buffer = buffer.substring(0, cmntpos).trim();
+ if (buffer.charAt(0) == '[' && buffer.charAt(buffer.length()-1) == ']') {
+ if (buffer.indexOf("l7vsadm") != -1 || buffer.indexOf("L7VSADM") != -1) {
+ startpos = i + 1;
+ } else {
+ if (startpos != 0) {
+ endpos = i;
+ break;
+ }
+ }
+ }
+ }
+ if( endpos == 0 ) endpos = datas.size();
+ if (data.admConInterval != 0)
+ searchInsertData(ADM_CMD_INTERVAL_KEY, String.valueOf(data.admCmdInterval),
+ datas, startpos, endpos += 1);
+ if (data.admCmdCount != 0)
+ searchInsertData(ADM_CMD_COUNT_KEY, String.valueOf(data.admCmdCount), datas,
+ startpos, endpos += 1);
+ if (data.admConInterval != 0)
+ searchInsertData(ADM_CON_INTERVAL_KEY, String.valueOf(data.admConInterval),
+ datas, startpos, endpos += 1);
+ if (data.admConCount != 0)
+ searchInsertData(ADM_CON_COUNT_KEY, String.valueOf(data.admConCount), datas,
+ startpos, endpos += 1);
+
+ //
+ //[replication]
+ startpos = 0;
+ endpos = 0;
+ for (int i = 0; i < datas.size(); ++i) {
+ String buffer = datas.get(i).trim();
+ if (buffer.length() == 0)
+ continue;
+ if (buffer.charAt(0) == '#')
+ continue;
+ int cmntpos = buffer.indexOf("#");
+ if (cmntpos != -1)
+ buffer = buffer.substring(0, cmntpos).trim();
+ if (buffer.charAt(0) == '[' && buffer.charAt(buffer.length()-1) == ']') {
+ if (buffer.indexOf("replication") != -1
+ || buffer.indexOf("REPLICATION") != -1) {
+ startpos = i + 1;
+ } else {
+ if (startpos != 0) {
+ endpos = i;
+ break;
+ }
+ }
+ }
+ }
+ if( endpos == 0 ) endpos = datas.size();
+ if (data.replicationOtherNode.host != null
+ && data.replicationOtherNode.host.length() != 0)
+ searchInsertData(REPLICATION_IPADDR_KEY, "\"" + data.replicationOtherNode.host
+ + "\"", datas, startpos, endpos += 1);
+ if (data.replicationOtherNode.port != null
+ && data.replicationOtherNode.port.length() != 0)
+ searchInsertData(REPLICATION_SERVICENAME_KEY, "\""
+ + data.replicationOtherNode.port + "\"", datas, startpos,
+ endpos += 1);
+ if (data.replicationNic != null && data.replicationNic.length() != 0)
+ searchInsertData(REPLICATION_NIC_KEY, "\"" + data.replicationNic + "\"",
+ datas, startpos, endpos += 1);
+ if (data.replicationInterval != 0)
+ searchInsertData(REPLICATION_INTERVAL_KEY, String
+ .valueOf(data.replicationInterval), datas, startpos,
+ endpos += 1);
+ if (data.component != null) {
+ int cmpno = 0;
+ for (java.util.Iterator<java.util.Map.Entry<String, Integer>> itr = data.component
+ .entrySet().iterator(); itr.hasNext();) {
+ java.util.Map.Entry<String, Integer> entry = itr.next();
+ StringBuffer compIdKey = new StringBuffer();
+ StringBuffer compSizeKey = new StringBuffer();
+ compIdKey.append(REPLICATION_COMPONENT_ID_BASE_KEY);
+ compSizeKey.append(REPLICATION_COMPONENT_SIZE_BASE_KEY);
+ if (cmpno < 10) {
+ compIdKey.append("0");
+ compSizeKey.append("0");
+ }
+ compIdKey.append(cmpno);
+ compSizeKey.append(cmpno);
+ searchInsertData(compIdKey.toString(), "\"" + entry.getKey() + "\"",
+ datas, startpos, endpos += 1);
+ searchInsertData(compSizeKey.toString(), String.valueOf(entry.getValue()),
+ datas, startpos, endpos += 1);
+ ++cmpno;
+ }
+ }
+
+ //
+ //[snmpagent]
+ //
+ startpos = 0;
+ endpos = 0;
+ for (int i = 0; i < datas.size(); ++i) {
+ String buffer = datas.get(i).trim();
+ if (buffer.length() == 0)
+ continue;
+ if (buffer.charAt(0) == '#')
+ continue;
+ int cmntpos = buffer.indexOf("#");
+ if (cmntpos != -1)
+ buffer = buffer.substring(0, cmntpos).trim();
+ if (buffer.charAt(0) == '[' || buffer.charAt(buffer.length()-1) == ']') {
+ if (buffer.indexOf("snmpagent") != -1
+ || buffer.indexOf("SNMPAGENT") != -1) {
+ startpos = i + 1;
+ } else {
+ if (startpos != 0) {
+ endpos = i;
+ break;
+ }
+ }
+ }
+ }
+ if( endpos == 0 ) endpos = datas.size();
+ if (data.snmpNIC != null && data.snmpNIC.length() != 0)
+ searchInsertData(SNMPAGENT_NIC_KEY, "\"" + data.snmpNIC + "\"", datas,
+ startpos, endpos += 1);
+ if (data.snmpIpAddr != null && data.snmpIpAddr.length() != 0)
+ searchInsertData(SNMPAGENT_IPADDR_KEY, "\"" + data.snmpIpAddr + "\"", datas,
+ startpos, endpos += 1);
+ if (data.snmpPort != null && data.snmpPort.length() != 0)
+ searchInsertData(SNMPAGENT_PORT_KEY, "\"" + data.snmpPort + "\"", datas,
+ startpos, endpos += 1);
+ if (data.snmpInterval != 0)
+ searchInsertData(SNMPAGENT_INTERVAL_KEY, String.valueOf(data.snmpInterval),
+ datas, startpos, endpos);
+
+ try {
+ java.io.File file = new java.io.File(FILENAME);
+ if (file.exists()) {
+ java.util.Date date = new java.util.Date();
+ java.io.File backfile = new java.io.File(FILENAME + ".back_"
+ + String.valueOf(date.getTime()));
+ file.renameTo(backfile);
+ file = new java.io.File(FILENAME);
+ }
+ java.io.FileWriter writer = new java.io.FileWriter(file);
+ for (java.util.Iterator<String> itr = datas.iterator(); itr.hasNext();) {
+ StringBuffer buf = new StringBuffer(itr.next());
+ buf.append('\n');
+ writer.write(buf.toString());
+ }
+ writer.flush();
+ } catch (Exception e) {
+ org.ultramonkey.l7.model.FileNotWriteException ex = new org.ultramonkey.l7.model.FileNotWriteException();
+ ex.setErrMessage("Cannot write file : " + FILENAME);
+ throw ex;
+ }
+
+ }
+
+ /**
+ *
+ * <p> getConfData method</p>
+ *
+ * @return l7vs.cf data
+ */
+ public synchronized L7vsConfData getConfData()
+ throws org.ultramonkey.l7.model.FileNotReadException {
+ return loadFromFile();
+ }
+
+ /**
+ *
+ * <p> setConfData method</p>
+ *
+ */
+ public synchronized void setConfData(L7vsConfData cf)
+ throws org.ultramonkey.l7.model.FileNotWriteException {
+ if (cf == null) {
+ org.ultramonkey.l7.model.FileNotWriteException exception = new org.ultramonkey.l7.model.FileNotWriteException();
+ exception.setErrMessage("L7vConfData class is null!");
+ exception.setErrNo(0);
+ throw exception;
+ }
+ saveToFile(cf);
+ }
+
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+import java.io.Serializable;
+import java.util.HashMap;
+
+/**
+ * <p>class L7vsConfData</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author nakai
+ */
+public class L7vsConfData implements Serializable {
+ static final long serialVersionUID = 1L;
+
+ /**
+ * l7vs.cf value of "[replication] nic"
+ */
+ public String replicationNic;
+
+ /**
+ * l7vs.cf value of "[replication] interval"
+ */
+ public int replicationInterval;
+
+ /**
+ * l7vs.cf value of "[replication] ip_addr, service_name"
+ */
+ public EndPoint replicationOtherNode;
+
+ /**
+ * l7vs.cf value of "[replication] component_xx" settings
+ */
+ public HashMap<String, Integer> component;
+
+ /**
+ * l7vs.cf value of "[snmpagent] interval"
+ */
+ public int snmpInterval;
+
+ /**
+ * l7vs.cf value of "[snmpagent] nic"
+ */
+ public String snmpNIC;
+
+ /**
+ * l7vs.cf value of "[snmpagent] ip_addr"
+ */
+ public String snmpIpAddr;
+
+ /**
+ * l7vs.cf value of "[snmpagent] port"
+ */
+ public String snmpPort;
+
+ /**
+ * l7vs.cf value of "[logger]" category settings.
+ */
+ public LogData logger;
+
+ /**
+ * l7vs.cf value of "[l7vsadm] cmd_interval"
+ */
+ public int admCmdInterval;
+
+ /**
+ * l7vs.cf value of "[l7vsadm] cmd_count"
+ */
+ public int admCmdCount;;
+
+ /**
+ * l7vs.cf value of "[l7vsadm] con_interval"
+ */
+ public int admConInterval;
+
+ /**
+ * l7vs.cf value of "[l7vsadm] con_count"
+ */
+ public int admConCount;
+
+ /**
+ *
+ * Constructor
+ *
+ */
+ public L7vsConfData() {
+ this.replicationOtherNode = new EndPoint();
+ this.logger = new LogData();
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+import java.io.File;
+import java.util.Date;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.FileNotReadException;
+import org.ultramonkey.l7.model.LogCategorySet;
+
+/**
+ *
+ * <p>class L7vsLogController</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tanuma
+ */
+public class L7vsLogController {
+
+ private Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE);
+
+ private static String GUI_LOG = "/var/log/l7vs/l7gui.log";
+ private static String SYNC_LOG = "/var/log/l7vs/l7sync.log";
+
+ /**
+ *
+ * <p> getData method</p>
+ *
+ * @return log setting data.
+ */
+ public LogData getData() {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11504 L7vsLogController::getData() in");
+ }
+ // --- debug log (in method) ---
+
+ synchronized (this) {
+ L7vsConfController confController = new L7vsConfController();
+ DirectorController direController = new DirectorController();
+ ClusterController haController = new ClusterController();
+ L7vsAdmController admController = new L7vsAdmController();
+ L7vsConfData cf = null;
+ DirectorData dd = null;
+ ClusterData cd = null;
+ L7vsAdmData ad = null;
+ LogData logData = new LogData();
+ try {
+ cf = confController.getConfData();
+ dd = direController.getDirectorData();
+ cd = haController.getData();
+ ad = admController.getData();
+
+ logData.admLog = setLogfile(cf.logger.admLog);
+
+ logData.lbLog = setLogfile(cf.logger.lbLog);
+ logData.lbLog.logLevel = ad.l7vsdLogLevel;
+
+ logData.snmpLog = setLogfile(cf.logger.snmpLog);
+ logData.snmpLog.logLevel = ad.snmpLogLevel;
+
+ cf.logger.directorLog.fileName = dd.logfile.replaceAll("\"", "");
+ logData.directorLog = setLogfile(cf.logger.directorLog);
+
+ cf.logger.guiLog.fileName = GUI_LOG;
+ logData.guiLog = setLogfile(cf.logger.guiLog);
+
+ cf.logger.haLog.fileName = cd.logFileName;
+ logData.haLog = setLogfile(cf.logger.haLog);
+
+ cf.logger.syncLog.fileName = SYNC_LOG;
+ logData.syncLog = setLogfile(cf.logger.syncLog);
+ } catch (FileNotReadException e) {
+ ioFileLogger.error("41216 Exception occured: " + e.getMessage());
+ logData = null;
+ } catch (Exception e) {
+ ioFileLogger.error("41217 Exception occured: " + e.getMessage());
+ logData = null;
+ }
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11505 L7vsLogController::getData() out return=("
+ + logData + ")");
+ }
+ // --- debug log (out method) ---
+ return logData;
+ }
+ }
+
+ protected LogSet setLogfile(LogSet logSet) {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7vsLogController::setLogfile(LogSet logSet) in ");
+ buf.append("cfLogSet=(" + logSet + ")");
+ ioFileLogger.debug("11506 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ int suffix = 0;
+ while (true) {
+ String path = logSet.fileName;
+ if (suffix > 0)
+ path += "." + suffix;
+
+ try {
+ File log = new File(path);
+ if (log.isFile())
+ logSet.logFiles.add(new LogFileData(log.getName(),
+ log.getAbsolutePath(), log.length(),
+ new Date(log.lastModified())));
+ else
+ break;
+ } catch (NullPointerException e) {
+ ioFileLogger.error("41218 Exception occured: " + e.getMessage());
+ } catch (Exception e) {
+ ioFileLogger.error("41219 Exception occured: " + e.getMessage());
+ }
+
+ suffix++;
+ }
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11507 L7vsLogController::setLogfile() out return=(" + logSet + ")");
+ }
+ // --- debug log (out method) ---
+
+ return logSet;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+import java.io.Serializable;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.LogCategorySet;
+
+/**
+ *
+ * <p>class LogData</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tanuma
+ */
+public class LogData extends LogSet implements Serializable{
+ static final long serialVersionUID = 1;
+
+ /**
+ *
+ * <p>class LogCategory</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tanuma
+ */
+ public enum LogCategory {
+ L7VSD_NETWORK,
+ L7VSD_NETWORK_BANDWIDTH,
+ L7VSD_NETWORK_NUM_CONNECTION,
+ L7VSD_NETWORK_QOS,
+ L7VSD_VIRTUAL_SERVICE,
+ L7VSD_REAL_SERVER,
+ L7VSD_SORRY_SERVER,
+ L7VSD_REAL_SERVER_BALANCING,
+ L7VSD_REPLICATION,
+ L7VSD_START_STOP,
+ L7VSD_SYSTEM,
+ L7VSD_SYSTEM_MEMORY,
+ L7VSD_SYSTEM_SOCKET,
+ L7VSD_SYSTEM_SIGNAL,
+ L7VSD_ENVIRONMENT,
+ L7VSD_ENVIRONMENT_PARAMETER,
+ L7VSD_LOGGER,
+ L7VSD_PARAMETER,
+ L7VSD_EVENT,
+ L7VSD_SCHEDULE,
+ L7VSD_PROGRAM,
+ L7VSD_PROTOCOL,
+ L7VSD_MODULE,
+ L7VSD_ALL,
+ SNMPAGENT_START_STOP,
+ SNMPAGENT_MANAGER_RECEIVE,
+ SNMPAGENT_MANAGER_SEND,
+ SNMPAGENT_L7VSD_RECEIVE,
+ SNMPAGENT_L7VSD_SEND,
+ SNMPAGENT_LOGGER,
+ SNMPAGENT_PARAMETER,
+ SNMPAGENT_ALL,
+ L7VSADM_PARSE,
+ L7VSADM_OPERATE,
+ L7VSADM_COMMUNICATE,
+ L7VSADM_CONFIG_RESULT,
+ L7VSADM_COMMON,
+ L7VSADM_LOGGER,
+ L7VSADM_PARAMETER,
+ L7VSADM_PROTOCOL,
+ L7VSADM_MODULE
+ }
+
+ /**
+ *
+ * <p>class LogLevel</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tanuma
+ */
+ public enum LogLevel {
+ NONE,
+ DEBUG,
+ INFO,
+ WARN,
+ ERROR,
+ FATAL
+ }
+
+ /**
+ * l7vsadm logging information
+ */
+ public LogSet admLog;
+
+ /**
+ * l7directord logging information
+ */
+ public LogSet directorLog;
+
+ /**
+ * l7gui logging information
+ */
+ public LogSet guiLog;
+
+ /**
+ * cluster logging information
+ */
+ public LogSet haLog;
+
+ /**
+ * l7vsd logging information
+ */
+ public LogSet lbLog;
+
+ /**
+ * l7agent logging information
+ */
+ public LogSet snmpLog;
+
+ /**
+ * l7sync logging information
+ */
+ public LogSet syncLog;
+
+ /**
+ *
+ * Constructor
+ *
+ */
+ public LogData() {
+ // --- debug log (constructor) ---
+ Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE);
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11522 class LogData created.");
+ }
+ // --- debug log (constructor) ---
+
+ admLog = new LogSet();
+ directorLog = new LogSet();
+ guiLog = new LogSet();
+ haLog = new LogSet();
+ lbLog = new LogSet();
+ snmpLog = new LogSet();
+ syncLog = new LogSet();
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public String toString() {
+ return
+ "admLog=(" + this.admLog + "), " +
+ "directorLog=(" + this.directorLog + "), " +
+ "guiLog=(" + this.guiLog + "), " +
+ "haLog=(" + this.haLog + "), " +
+ "lbLog=(" + this.lbLog + "), " +
+ "snmpLog=(" + this.snmpLog + "), " +
+ "syncLog=(" + this.syncLog + ")";
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+import java.util.Date;
+import java.io.Serializable;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.LogCategorySet;
+
+/**
+ *
+ * <p>class LogFileData</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tanuma
+ */
+public class LogFileData implements Serializable {
+ static final long serialVersionUID = 1;
+
+ /**
+ * file name (ex. l7vsd.log, l7vsadm.log.2)
+ */
+ public String fileName;
+
+ /**
+ * file path include file name (ex. /var/log/l7vsd.log.4)
+ */
+ public String filePath;
+
+ /**
+ * file size
+ */
+ public long size;
+
+ /**
+ * file mdate
+ */
+ public Date time;
+
+ /**
+ *
+ * Constructor
+ *
+ */
+ public LogFileData() {
+ // --- debug log (constructor) ---
+ Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE);
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11520 class LogFileData created.");
+ }
+ // --- debug log (constructor) ---
+
+ this.fileName = null;
+ this.filePath = null;
+ this.size = 0;
+ this.time = new Date();
+ }
+
+ /**
+ *
+ * Constructor
+ *
+ * @param fileName
+ * @param filePath
+ * @param size
+ * @param time
+ */
+ public LogFileData(String fileName, String filePath, long size, Date time) {
+ // --- debug log (constructor) ---
+ Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE);
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11521 class LogFileData created.");
+ }
+ // --- debug log (constructor) ---
+
+ this.fileName = fileName;
+ this.filePath = filePath;
+ this.size = size;
+ this.time = time;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public String toString() {
+ return
+ "fileName=\"" + this.fileName + "\", " +
+ "filePath=\"" + this.filePath + "\", " +
+ "size=" + this.size + ", " +
+ "time=(" + this.time + ")";
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Vector;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.LogCategorySet;
+
+public class LogSet extends LogFileData implements Serializable {
+ static final long serialVersionUID = 1;
+
+ /**
+ * log file name
+ */
+ public String fileName = "";
+
+ /**
+ * rotate setting
+ */
+ public String rotation = "";
+
+ /**
+ * backup file number
+ */
+ public int maxBackupIndex = 0;
+
+ /**
+ * rotate size
+ */
+ public String maxFileSize = "";
+
+ /**
+ * rotation timing pattern
+ */
+ public String rotationTiming = "";
+
+ /**
+ * rotation timing value
+ */
+ public String rotationTimingValue = "";
+
+ /**
+ * log files data
+ */
+ public Vector<LogFileData> logFiles;
+
+ /**
+ * log level data
+ */
+ public HashMap<LogData.LogCategory, LogData.LogLevel> logLevel;
+
+ /**
+ *
+ * Constructor
+ *
+ */
+ public LogSet() {
+ // --- debug log (constructor) ---
+ Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE);
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11523 class LogSet created.");
+ }
+ // --- debug log (constructor) ---
+
+ this.logFiles = new Vector<LogFileData>();
+ this.logLevel = new HashMap<LogData.LogCategory, LogData.LogLevel>();
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public String toString() {
+ return
+ "fileName=\"" + this.fileName + "\", " +
+ "maxBackupIndex=" + this.maxBackupIndex + ", " +
+ "maxFileSize=\"" + this.maxFileSize + "\", " +
+ "rotation=\"" + this.rotation + "\", " +
+ "rotationTiming=\"" + this.rotationTiming + "\", " +
+ "rotationTimingValue=\"" + this.rotationTimingValue + "\", " +
+ "logFiles=(" + this.logFiles + "), " +
+ "logLevel=(" + this.logLevel + ")";
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+import java.io.Serializable;
+import java.util.HashMap;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.LogCategorySet;
+
+/**
+ *
+ * <p>class ReplicationData</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tanuma
+ */
+public class ReplicationData implements Serializable {
+ static final long serialVersionUID = 1L;
+
+ /**
+ * Replication Status (MASTER, MASTER_STOP, SLAVE, SLAVE_STOP, SINGLE, OUT)
+ */
+ public ReplicationStatus replicationMode;
+
+ /**
+ * Network Interface name of using for replication
+ */
+ public String nic;
+
+ /**
+ * IP address and port number of the other node
+ */
+ public EndPoint otherNode;
+
+ /**
+ * Replication interval seconds
+ */
+ public int interval;
+
+ /**
+ * Replication component setting
+ */
+ public HashMap<String, Integer> component;
+
+ /**
+ *
+ * Constructor
+ *
+ */
+ public ReplicationData() {
+ // --- debug log (constructor) ---
+ Logger repLogger = Logger.getLogger(LogCategorySet.GUI_REPLICATION);
+ if (repLogger.isDebugEnabled()) {
+ repLogger.debug("11508 class ReplicationData created.");
+ }
+ // --- debug log (constructor) ---
+
+ this.replicationMode = ReplicationStatus.MASTER_STOP;
+ this.nic = "";
+ this.otherNode = new EndPoint();
+ this.interval = 0;
+ this.component = new HashMap<String, Integer>();
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public String toString() {
+ return
+ "replicationMode=" + this.replicationMode + ", " +
+ "nic=\"" + this.nic + "\", " +
+ "otherNode=(" + this.otherNode + "), " +
+ "interval=" + this.interval + ", " +
+ "component=(" + this.component + ")";
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+/**
+ * <p>class ReplicationStatus</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tanuma
+ */
+public enum ReplicationStatus {
+ /**
+ * master mode
+ */
+ MASTER,
+ /**
+ * master stop mode
+ */
+ MASTER_STOP,
+ /**
+ * slave mode
+ */
+ SLAVE,
+ /**
+ * slave stop mode
+ */
+ SLAVE_STOP,
+ /**
+ * single mode
+ */
+ SINGLE,
+ /**
+ * no replication setting
+ */
+ OUT,
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+import java.io.Serializable;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.LogCategorySet;
+
+/**
+ *
+ * <p>class SnmpAgentData</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tanuma
+ */
+public class SnmpAgentData implements Serializable {
+ static final long serialVersionUID = 1;
+
+ /**
+ * SNMP Agent interval
+ */
+ public int interval;
+
+ /**
+ * SNMP Agent status
+ */
+ public SnmpAgentStatus status;
+
+ /**
+ *
+ * Constructor
+ *
+ */
+ public SnmpAgentData() {
+ // --- debug log (constructor) ---
+ Logger snmpLogger = Logger.getLogger(LogCategorySet.GUI_IO);
+ if (snmpLogger.isDebugEnabled()) {
+ snmpLogger.debug("11500 class SnmpAgentData created.");
+ }
+ // --- debug log (constructor) ---
+
+ this.interval = -1;
+ this.status = SnmpAgentStatus.NON_CONNECTING;
+ }
+
+ /**
+ *
+ * <p> equals method</p>
+ *
+ * @param snmpData
+ * @return
+ */
+ public boolean equals(SnmpAgentData snmpData) {
+ // --- debug log (in method) ---
+ Logger snmpLogger = Logger.getLogger(LogCategorySet.GUI_IO);
+ if (snmpLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("SnmpAgentData::equals(SnmpAgentData snmpData) in ");
+ buf.append("snmpData=(" + snmpData + ")");
+ snmpLogger.debug("11501 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ if (snmpData != null && this.interval == snmpData.interval &&
+ this.status == snmpData.status) {
+ // --- debug log (out method) ---
+ if (snmpLogger.isDebugEnabled()) {
+ snmpLogger.debug("11502 SnmpAgentData::equals(snmpData) out return=true");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+
+ // --- debug log (out method) ---
+ if (snmpLogger.isDebugEnabled()) {
+ snmpLogger.debug("11503 SnmpAgentData::equals(snmpData) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+/**
+ * <p>class ControlerStatus</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author nakai
+ */
+public enum SnmpAgentStatus {
+ /**
+ * connecting
+ */
+ CONNECTING,
+ /**
+ * non-connecting
+ */
+ NON_CONNECTING,
+}
--- /dev/null
+package org.ultramonkey.l7.controller;
+
+import java.io.Serializable;
+import java.util.Vector;
+import java.util.regex.*;
+
+/**
+ *
+ * <p>
+ * class VirtualSetting
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author tanuma
+ */
+public class VirtualSetting implements Serializable {
+ static final long serialVersionUID = 1;
+
+ /**
+ * virtual service
+ */
+ public EndPoint virtual;
+
+ /**
+ * real server
+ */
+ public Vector<EndPoint> real;
+
+ /**
+ * protocol module name
+ */
+ public String protomod = "";
+
+ /**
+ * protocol module option strings
+ */
+ public String option = "";
+
+ /**
+ * protocol module reschedule flag
+ */
+ public boolean reschedule;
+
+ /**
+ * scheduler name
+ */
+ public String sched = "";
+
+ /**
+ * max connection setting
+ */
+ public int maxconn;
+
+ /**
+ * QoS limit per virtual service
+ */
+ public long qosservice;
+
+ /**
+ * QoS limit per client
+ */
+ public long qosclient;
+
+ /**
+ * current throughput
+ */
+ public long throughput;
+
+ /**
+ * sorry server
+ */
+ public EndPoint sorryserver;
+
+ /**
+ * sorry flag
+ */
+ public boolean sorryflag;
+
+ /**
+ * timeout of real server monitor
+ */
+ public int timeout;
+
+ /**
+ * check count of real server monitor
+ */
+ public int checkcount;
+
+ /**
+ * connection type of real server monitor
+ */
+ public String checktype = "";
+
+ /**
+ * service type of real server monitor
+ */
+ public String service = "";
+
+ /**
+ * quiescent flag
+ */
+ public String quiescent = "";
+
+ /**
+ * check port of real server monitor
+ */
+ public int checkport;
+
+ /**
+ * request string of real server monitor
+ */
+ public String request = "";
+
+ /**
+ * response string of real server monitor
+ */
+ public String receive = "";
+
+ /**
+ * HTTP method of real server monitor
+ */
+ public String httpmethod = "";
+
+ /**
+ * HTTP virtual host of real server monitor
+ */
+ public String virtualhost = "";
+
+ /**
+ * login user name for real server monitor
+ */
+ public String login = "";
+
+ /**
+ * password for real server monitor
+ */
+ public String passwd = "";
+
+ /**
+ * database name for real server monitor
+ */
+ public String database = "";
+
+ /**
+ * protocol name
+ */
+ public String protocol = "";
+
+ /**
+ * real server down callback script file path
+ */
+ public String downcallback = "";
+
+ /**
+ * real server up callback script file path
+ */
+ public String upcallback = "";
+
+ /**
+ * virtual position in l7directord.cf
+ */
+ int cfPosition = 0;
+
+ /**
+ *
+ * Constructor
+ *
+ */
+ public VirtualSetting() {
+ this.virtual = new EndPoint();
+ this.real = new Vector<EndPoint>();
+ this.sorryserver = new EndPoint();
+ }
+
+ /**
+ *
+ * Copy Constructor
+ *
+ * @param v
+ */
+ public VirtualSetting(VirtualSetting v) {
+ this.virtual = new EndPoint(v.virtual);
+ this.real = (Vector<EndPoint>) v.real.clone();
+ this.protomod = new String(v.protomod);
+ this.option = new String(v.option);
+ this.sched = new String(v.sched);
+ this.maxconn = v.maxconn;
+ this.qosservice = v.qosservice;
+ this.qosclient = v.qosclient;
+ this.sorryserver = new EndPoint(v.sorryserver);
+ this.sorryflag = v.sorryflag;
+ this.timeout = v.timeout;
+ this.checkcount = v.checkcount;
+ this.checktype = new String(v.checktype);
+ this.service = new String(v.service);
+ this.quiescent = new String(v.quiescent);
+ this.checkport = v.checkport;
+ this.request = new String(v.request);
+ this.receive = new String(v.receive);
+ this.httpmethod = new String(v.httpmethod);
+ this.virtualhost = new String(v.virtualhost);
+ this.login = new String(v.login);
+ this.passwd = new String(v.passwd);
+ this.database = new String(v.database);
+ this.protocol = new String(v.protocol);
+ this.downcallback = new String(v.downcallback);
+ this.upcallback = new String(v.upcallback);
+ }
+
+ /**
+ *
+ * <p>
+ * complementOption method
+ * </p>
+ *
+ * @param vs
+ * @return
+ */
+ public void complementOption() {
+ String fullOption = "";
+ if (this.protomod == null || this.option == null)
+ return;
+ if (this.protomod.equals("cinsert")) {
+ Pattern p = Pattern.compile("(?:--cookie-name|-C)\\s+([^\\s]+)");
+ Matcher m = p.matcher(this.option);
+ if (m.find())
+ fullOption = "--cookie-name " + m.group(1);
+ else {
+ fullOption = "--cookie-name CookieName";
+ }
+ p = Pattern.compile("(?:--cookie-expire|-E)\\s+(\\d+)");
+ m = p.matcher(this.option);
+ if (m.find())
+ fullOption += " --cookie-expire " + m.group(1);
+ else {
+ fullOption += " --cookie-expire 86400";
+ }
+ p = Pattern.compile("(?:--forwarded-for|-F)");
+ m = p.matcher(this.option);
+ if (m.find())
+ fullOption += " --forwarded-for";
+ p = Pattern.compile("(?:--reschedule|-R)");
+ m = p.matcher(this.option);
+ if (m.find())
+ fullOption += " --reschedule";
+ p = Pattern.compile("(?:--no-reschedule|-N)");
+ m = p.matcher(this.option);
+ if (m.find())
+ fullOption += " --no-reschedule";
+ }
+ else if (this.protomod.equals("url")) {
+ Pattern p = Pattern.compile("(?:--pattern-match|-P)\\s+([^\\s]+)");
+ Matcher m = p.matcher(this.option);
+ if (m.find())
+ fullOption = "--pattern-match " + m.group(1);
+ p = Pattern.compile("(?:--forwarded-for|-F)");
+ m = p.matcher(this.option);
+ if (m.find())
+ fullOption += " --forwarded-for";
+ }
+ else if (this.protomod.equals("sessionless")) {
+ Pattern p = Pattern.compile("(?:--forwarded-for|-F)");
+ Matcher m = p.matcher(this.option);
+ if (m.find())
+ fullOption += "--forwarded-for";
+ }
+ else if (this.protomod.equals("sslid")) {
+ Pattern p = Pattern.compile("(?:--timeout|-T)\\s+(\\d+)");
+ Matcher m = p.matcher(this.option);
+ if (m.find())
+ fullOption += "--timeout " + m.group(1);
+ else {
+ fullOption += "--timeout 3600";
+ }
+ p = Pattern.compile("(?:--maxlist|-M)\\s+(\\d+)");
+ m = p.matcher(this.option);
+ if (m.find())
+ fullOption += " --maxlist " + m.group(1);
+ else {
+ fullOption += " --maxlist 1024";
+ }
+ p = Pattern.compile("(?:--reschedule|-R)");
+ m = p.matcher(this.option);
+ if (m.find())
+ fullOption += " --reschedule";
+ p = Pattern.compile("(?:--no-reschedule|-N)");
+ m = p.matcher(this.option);
+ if (m.find())
+ fullOption += " --no-reschedule";
+ }
+ this.option = fullOption;
+ }
+
+ /**
+ *
+ * <p>
+ * isSameService method
+ * </p>
+ *
+ * @param vs
+ * @return
+ */
+ public boolean isSameService(VirtualSetting vs) {
+ if (this.virtual.equals(vs.virtual) && this.isSameKey(vs)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * <p>
+ * isSameKey method
+ * </p>
+ *
+ * @param vs
+ * @return
+ */
+ public boolean isSameKey(VirtualSetting vs) {
+ if (this.protomod.equals(vs.protomod)) {
+ String key1 = this.getKey();
+ String key2 = vs.getKey();
+ if (key1 != null && key2 != null && key1.equals(key2))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * <p>
+ * getKey method
+ * </p>
+ *
+ * @return
+ */
+ public String getKey() {
+ if (this.protomod == null || this.option == null)
+ return null;
+ this.complementOption();
+ if (this.protomod.equals("cinsert")) {
+ Pattern p = Pattern.compile("--cookie-name\\s+([^\\s]+)");
+ Matcher m = p.matcher(this.option);
+ if (m.find())
+ return m.group(1).replaceAll("['\"]", "");
+ else
+ return null;
+ }
+ if (this.protomod.equals("url")) {
+ Pattern p = Pattern.compile("--pattern-match\\s+([^\\s]+)");
+ Matcher m = p.matcher(this.option);
+ if (m.find())
+ return m.group(1).replaceAll("['\"]", "");
+ else
+ return null;
+ }
+ if (this.protomod.equals("sslid"))
+ return "";
+ if (this.protomod.equals("sessionless"))
+ return "";
+
+ return null;
+ }
+
+ /**
+ *
+ * <p>
+ * equals method
+ * </p>
+ *
+ * @param vs
+ * @return
+ */
+ public boolean equals(VirtualSetting vs) {
+ this.complementOption();
+ vs.complementOption();
+ if (this.virtual.equals(vs.virtual)
+ && this.protomod.equals(vs.protomod)
+ && this.option.equals(vs.option)
+ && this.sched.equals(vs.sched)
+ && this.maxconn == vs.maxconn
+ && this.qosservice == vs.qosservice
+ && this.qosclient == vs.qosclient
+ && this.sorryserver.equals(vs.sorryserver)
+ && this.sorryflag == vs.sorryflag
+ && this.timeout == vs.timeout
+ && this.checkcount == vs.checkcount
+ && this.checktype.equals(vs.checktype)
+ && this.service.equals(vs.service)
+ && this.quiescent == vs.quiescent
+ && this.checkport == vs.checkport
+ && this.request.equals(vs.request)
+ && this.receive.equals(vs.receive)
+ && this.httpmethod.equals(vs.httpmethod)
+ && this.virtualhost.equals(vs.virtualhost)
+ && this.login.equals(vs.login) && this.passwd.equals(vs.passwd)
+ && this.database.equals(vs.database)
+ && this.protocol.equals(vs.protocol)
+ && this.downcallback.equals(vs.downcallback)
+ && this.upcallback.equals(vs.upcallback)) {
+ if (this.real == null && vs.real == null)
+ return true;
+ if (this.real.size() == vs.real.size()) {
+ int sameCount = 0;
+ for (EndPoint e1: this.real) {
+ for (EndPoint e2: vs.real) {
+ if (e1.equals(e2)) {
+ sameCount++;
+ }
+ }
+ }
+ if (sameCount == this.real.size())
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * <p>
+ * equalsAdm method
+ * </p>
+ *
+ * @param vs
+ * @return
+ */
+ public boolean equalsAdm(VirtualSetting vs) {
+ this.complementOption();
+ vs.complementOption();
+ if (this.virtual.equals(vs.virtual)
+ && this.protomod.equals(vs.protomod)
+ && this.option.equals(vs.option) && this.sched.equals(vs.sched)
+ && this.maxconn == vs.maxconn
+ && this.qosservice == vs.qosservice
+ && this.qosclient == vs.qosclient
+ && this.sorryserver.equals(vs.sorryserver)) {
+ if (this.real == null && vs.real == null)
+ return true;
+ if (this.real.size() == vs.real.size()) {
+ int sameCount = 0;
+ for (EndPoint e1: this.real) {
+ for (EndPoint e2: vs.real) {
+ if (e1.equals(e2)) {
+ sameCount++;
+ }
+ }
+ }
+ if (sameCount == this.real.size())
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public String toString() {
+ return
+ "virtual=(" + this.virtual + "), " +
+ "real=(" + this.real + "), " +
+ "protomod=\"" + this.protomod + "\", " +
+ "option=\"" + this.option + "\", " +
+ "sched=\"" + this.sched + "\", " +
+ "maxconn=" + this.maxconn + ", " +
+ "qosservice=" + this.qosservice + ", " +
+ "qosclient=" + this.qosclient + ", " +
+ "sorryserver=(" + this.sorryserver + "), " +
+ "sorryflag=" + this.sorryflag + ", " +
+ "timeout=" + this.timeout + ", " +
+ "checkcount=" + this.checkcount + ", " +
+ "checktype=\"" + this.checktype + "\", " +
+ "service=\"" + this.service + "\", " +
+ "quiescent=\"" + this.quiescent + "\", " +
+ "checkport=\"" + this.checkport + "\", " +
+ "request=\"" + this.request + "\", " +
+ "receive=\"" + this.receive + "\", " +
+ "httpmethod=\"" + this.httpmethod + "\", " +
+ "virtualhost=\"" + this.virtualhost + "\", " +
+ "login=\"" + this.login + "\", " +
+ "passwd=\"" + this.passwd + "\", " +
+ "database=\"" + this.database + "\", " +
+ "protocol=\"" + this.protocol + "\", " +
+ "downcallback=\"" + this.downcallback + "\", " +
+ "upcallback=\"" + this.upcallback + "\"";
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+public interface ErrNo {
+ public static final int INFONUMBER = 20000;
+ public static final int ERRORNUMBER = 40000;
+
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+/**
+ * <p>class ExecuteMode</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author nakai
+ */
+public enum ExecuteMode {
+ DIRECTOR_SAVE, //
+ DIRECTOR_SAVESYNC, //
+
+ VS_ADD_APPLY, //
+ VS_ADD_SAVE, //
+ VS_ADD_SAVESYNC, //
+
+ VS_REMOVE_APPLY, //
+ VS_REMOVE_SAVE, //
+ VS_REMOVE_SAVESYNC, //
+
+ VS_MODIFY_APPLY, //
+ VS_MODIFY_SAVE, //
+ VS_MODIFY_SAVESYNC, //
+
+ CLUSTER_SWITCHORVER, //
+
+ REP_MASTER, //
+ REP_MASTER_STOP, //
+ REP_SLAVE, //
+ REP_SLAVE_STOP, //
+ REP_INFO_SAVE, //
+ REP_INFO_SAVESYNC, //
+ REP_START, //
+
+ LOGLEVEL_CHANGE_APPLY, //
+ LOGLEVEL_CHANGE_SAVE, //
+ LOGLEVEL_CHANGE_SAVESYNC, //
+
+ SNMP_INFO_SAVE, //
+ SNMP_INFO_SAVESYNC, //
+
+ SYNC, //
+
+ NONE
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * <p>class FileNotReadException</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tanuma
+ */
+public class FileNotReadException extends Exception {
+ static final long serialVersionUID = 1L;
+
+ private Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE);
+
+ protected String fileName = "";
+
+ protected int errno = 0;
+
+ protected String errMessage = "";
+
+ /**
+ *
+ * Constructor
+ *
+ */
+ public FileNotReadException() {
+ // --- debug log (constructor) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11045 class FileNotReadException created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /**
+ *
+ * <p> getFileName method</p>
+ *
+ * @return
+ */
+ public String getFileName() {
+ // --- debug log (in/out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11046 FileNotReadException::getFileName() in");
+ ioFileLogger.debug("11047 FileNotReadException::getFileName() out return=\"" + this.fileName + "\"");
+ }
+ // --- debug log (in/out method) ---
+ return this.fileName;
+ }
+
+ /**
+ *
+ * <p> setFileName method</p>
+ *
+ * @param fileName
+ */
+ public void setFileName(String fileName) {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11048 FileNotReadException::setFileName(String fileName) in fileName=\"" + fileName + "\"");
+ }
+ // --- debug log (in method) ---
+
+ this.fileName = fileName;
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11049 FileNotReadException::getFileName(String fileName) out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ /**
+ *
+ * <p> getErrno method</p>
+ *
+ * @return
+ */
+ public int getErrno() {
+ // --- debug log (in/out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11050 FileNotReadException::getErrno() in");
+ ioFileLogger.debug("11051 FileNotReadException::getErrno() out return=" + this.errno);
+ }
+ // --- debug log (in/out method) ---
+ return errno;
+ }
+
+ /**
+ *
+ * <p> setErrNo method</p>
+ *
+ * @param errno
+ */
+ public void setErrNo(int errno) {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11052 FileNotReadException::setErrno(String errno) in errno=" + errno);
+ }
+ // --- debug log (in method) ---
+
+ this.errno = errno;
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11053 FileNotReadException::getErrno(String errno) out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ /**
+ *
+ * <p> getErrMessage method</p>
+ *
+ * @return
+ */
+ public String getErrMessage() {
+ // --- debug log (in/out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11054 FileNotReadException::getErrMessage() in");
+ ioFileLogger.debug("11055 FileNotReadException::getErrMessage() out return=\"" + this.errMessage + "\"");
+ }
+ // --- debug log (in/out method) ---
+ return errMessage;
+ }
+
+ /**
+ *
+ * <p> setErrMessage method</p>
+ *
+ * @param errMessage
+ */
+ public void setErrMessage(String errMessage) {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11056 FileNotReadException::setErrMessage(String errMessage) in errMessage=\"" + errMessage + "\"");
+ }
+ // --- debug log (in method) ---
+
+ this.errMessage = errMessage;
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11057 FileNotReadException::setErrMessage(String errMessage) out");
+ }
+ // --- debug log (out method) ---
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * <p>class FileNotWriteException</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tanuma
+ */
+public class FileNotWriteException extends Exception {
+ static final long serialVersionUID = 1L;
+
+ private Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE);
+
+ protected String fileName = "";
+
+ protected int errno = 0;
+
+ protected String errMessage = "";
+
+ /**
+ *
+ * Constructor
+ *
+ */
+ public FileNotWriteException() {
+ // --- debug log (constructor) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11162 class FileNotWriteException created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /**
+ *
+ * <p> getFileName method</p>
+ *
+ * @return
+ */
+ public String getFileName() {
+ // --- debug log (in/out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11163 FileNotWriteException::getFileName() in");
+ ioFileLogger.debug("11164 FileNotWriteException::getFileName() out return=\"" + this.fileName + "\"");
+ }
+ // --- debug log (in/out method) ---
+ return this.fileName;
+ }
+
+ /**
+ *
+ * <p> setFileName method</p>
+ *
+ * @param fileName
+ */
+ public void setFileName(String fileName) {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11165 FileNotWriteException::setFileName(String fileName) in fileName=\"" + this.fileName + "\"");
+ }
+ // --- debug log (in method) ---
+
+ this.fileName = fileName;
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11166 FileNotWriteException::setFileName(String fileName) out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ /**
+ *
+ * <p> getErrno method</p>
+ *
+ * @return
+ */
+ public int getErrno() {
+ // --- debug log (in/out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11167 FileNotWriteException::getErrno() in");
+ ioFileLogger.debug("11168 FileNotWriteException::getErrno() out return=" + this.errno);
+ }
+ // --- debug log (in/out method) ---
+ return this.errno;
+ }
+
+ /**
+ *
+ * <p> setErrNo method</p>
+ *
+ * @param errno
+ */
+ public void setErrNo(int errno) {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11169 FileNotWriteException::setErrno(String errno) in errno=" + this.errno);
+ }
+ // --- debug log (in method) ---
+
+ this.errno = errno;
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11170 FileNotWriteException::setErrno(String errno) out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ /**
+ *
+ * <p> getErrMessage method</p>
+ *
+ * @return
+ */
+ public String getErrMessage() {
+ // --- debug log (in/out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11171 FileNotWriteException::getErrMessage() in");
+ ioFileLogger.debug("11172 FileNotWriteException::getErrMessage() out return=\"" + this.errMessage + "\"");
+ }
+ // --- debug log (in/out method) ---
+ return errMessage;
+ }
+
+ /**
+ *
+ * <p> setErrMessage method</p>
+ *
+ * @param errMessage
+ */
+ public void setErrMessage(String errMessage) {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11173 FileNotWriteException::setErrMessage(String errMessage) in errMessage=\"" + this.errMessage + "\"");
+ }
+ // --- debug log (in method) ---
+
+ this.errMessage = errMessage;
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11174 FileNotWriteException::setErrMessage(String errMessage) out");
+ }
+ // --- debug log (out method) ---
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+import java.util.HashSet;
+
+import org.apache.log4j.Logger;
+
+/**
+ * <p>class L7SyncCommand</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author momose
+ */
+public class L7SyncCommand {
+ protected static Logger debugLogger = Logger.getLogger(LogCategorySet.SYNC_SYNC);
+
+ protected HashSet<Integer> categorySet;
+
+ protected int serverMode = 0;
+
+ private static final int ACT_MODE = 1;
+
+ private static final int SBY_MODE = 2;
+
+ private static final int MODE_ERROR = 3;
+
+ private static final int UNDESIGNED_MODE = 0;
+
+ private int MODE_LOCATION = 0;
+
+ private int CATEGORY_START_LOCATION = MODE_LOCATION + 1;
+
+ protected Logger logger = Logger.getLogger(LogCategorySet.SYNC_SYNC);
+
+ /**
+ * Constructor
+ *
+ * @param args
+ */
+ public L7SyncCommand(String[] args) {
+ // debug log(constructor)
+ if (debugLogger.isDebugEnabled()) {
+ debugLogger.debug("11232 class L7SyncCommand created.");
+ }
+
+ categorySet = new HashSet<Integer>();
+ try {
+ this.checkArgument(args);
+ } catch (MessageView m) {
+ System.out.println(Message.SYNC_INVALID_ARGUMENT + " L7SyncCommand.");
+ logger.info("21032 " + Message.SYNC_INVALID_ARGUMENT + " L7SyncCommand.");
+ }
+ }
+
+ /**
+ * <p> checks arguments</p>
+ *
+ * @param args argument value from command line
+ * @throws MessageView
+ */
+ protected void checkArgument(String[] args) throws MessageView {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncCommand::checkArgument(String[] args) throws MessageView in args= ");
+ if (0 != args.length) {
+ for (int i = 0; i < args.length; i++) {
+ if (args.length - 1 == i) {
+ buf.append(args[i].toString());
+ break;
+ }
+ buf.append(args[i].toString() + ",");
+ }
+ } else {
+ buf.append("null");
+ }
+ debugLogger.debug("11233 " + buf.toString());
+ }
+
+ if (0 == args.length) {
+ setServerMode(UNDESIGNED_MODE);
+ } else if (args[MODE_LOCATION].equals("-a")) {
+ setServerMode(ACT_MODE);
+ if (args.length <= CATEGORY_START_LOCATION) {
+ throw new MessageView(40024, LogCategorySet.SYNC_SYNC,
+ Message.SYNC_INVALID_ARGUMENT + " checkArgument.");
+ }
+ for (int i = CATEGORY_START_LOCATION; i < args.length; i++) {
+ try {
+ setCaterogyIdSet(SyncCategoryIdSet.toCategoryId(args[i]));
+ } catch (MessageView m) {
+ throw new MessageView(40025, LogCategorySet.SYNC_SYNC,
+ Message.SYNC_INVALID_ARGUMENT + " checkArgument.");
+ }
+ }
+ } else if (args[MODE_LOCATION].equals("-s")) {
+ setServerMode(SBY_MODE);
+ } else {
+ setServerMode(MODE_ERROR);
+ throw new MessageView(40026, LogCategorySet.SYNC_SYNC,
+ Message.SYNC_INVALID_ARGUMENT + " checkArgument.");
+ }
+
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncCommand::checkArgument(String[] args) throws MessageView out ");
+ debugLogger.debug("11234 " + buf.toString());
+ }
+
+ }
+
+ /**
+ * <p> starts L7GUI synchronous processing</p>
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncCommand::main(String[] args) in args= ");
+ if (0 == args.length) {
+ buf.append("null");
+ } else {
+ for (int i = 0; i < args.length; i++) {
+ if (args.length - 1 == i) {
+ buf.append(args[i].toString());
+ break;
+ }
+ buf.append(args[i].toString() + ",");
+ }
+ }
+ debugLogger.debug("11235 " + buf.toString());
+ }
+
+ if (0 == args.length) {
+ L7SyncCommand.usage();
+
+ } else {
+ L7SyncCommand l7SyncCommand = new L7SyncCommand(args);
+ l7SyncCommand.start();
+ }
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncCommand::main(String[] args) out ");
+ debugLogger.debug("11236 " + buf.toString());
+ }
+
+ }
+
+ /**
+ * <p> starts active or stand-by processing</p>
+ *
+ */
+ protected void start() {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncCommand::start() in ");
+ debugLogger.debug("11237 " + buf.toString());
+ }
+
+ L7SyncManager l7SyncManager = new L7SyncManager();
+ switch (serverMode) {
+ case ACT_MODE:
+ try {
+ l7SyncManager.syncAct(getCategoryIdSet());
+ } catch (MessageView m) {
+ System.out.println(m.message);
+ }
+ break;
+
+ case SBY_MODE:
+ try {
+ l7SyncManager.syncSby();
+ } catch (MessageView m) {
+ System.out.println(m.message);
+ }
+ break;
+ default:
+ System.out.println(Message.SYNC_INVALID_SERVER_MODE);
+ break;
+ }
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncCommand::start() out ");
+ debugLogger.debug("11238 " + buf.toString());
+ }
+
+ }
+
+ /**
+ * <p> shows how to use L7SyncCommand</p>
+ *
+ */
+ protected static void usage() {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncCommand::usage() in ");
+ debugLogger.debug("11239 " + buf.toString());
+ }
+
+ System.out.println(
+ "Usage: L7SyncCommand -a [CATEGORY]...\n" +
+ " L7SyncCommand -s\n" +
+ "\n" +
+ "Commands:\n" +
+ " -a active mode. send specified category data to standby server.\n" +
+ " -s standby mode. receive data from active server.\n" +
+ "\n" +
+ "Category:\n" +
+ " l7vsd_log log settings of l7vsd\n" +
+ " adm_log log settings of l7vsadm\n" +
+ " snmp_log log settings of l7agent\n" +
+ " log_all all log settings\n" +
+ " adm_info command settings of l7vsadm\n" +
+ " replication_info replication settings of l7vsd\n" +
+ " snmp_info interval settings of l7agent\n" +
+ " monitor global settings of l7directord.cf\n" +
+ " service virtual settings of l7directord.cf\n" +
+ " userdata user data of l7gui\n"
+ );
+
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncCommand::usage() out ");
+ debugLogger.debug("11240 " + buf.toString());
+ }
+
+ }
+
+ /**
+ * <p> gets CategoryIdSet</p>
+ *
+ * @return categorySet
+ */
+ protected HashSet<Integer> getCategoryIdSet() {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncCommand::getCategoryIdSet() in ");
+ debugLogger.debug("11241 " + buf.toString());
+ }
+
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncCommand::getCategoryIdSet() out ");
+ buf.append("return= " + categorySet.toString());
+ debugLogger.debug("11242 " + buf.toString());
+ }
+
+ return categorySet;
+ }
+
+ /**
+ * <p> sets CaterogyIdSet</p>
+ *
+ * @param categoryId
+ */
+ protected void setCaterogyIdSet(Integer categoryId) {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncCommand::setCaterogyIdSet() in ");
+ debugLogger.debug("11243 " + buf.toString());
+ }
+ categorySet.add(categoryId);
+
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncCommand::setCaterogyIdSet() out ");
+ debugLogger.debug("11244 " + buf.toString());
+ }
+ }
+
+ /**
+ * <p> gets serverMode</p>
+ *
+ * @return
+ */
+ protected int getServerMode() {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncCommand::getServerMode() in ");
+ debugLogger.debug("11245 " + buf.toString());
+ }
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncCommand::getServerMode() out ");
+ buf.append("return= " + serverMode);
+ debugLogger.debug("11246 " + buf.toString());
+ }
+ return serverMode;
+ }
+
+ /**
+ * <p> sets serverMode</p>
+ *
+ * @param mode
+ */
+ protected void setServerMode(int mode) {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncCommand::setServerMode() in ");
+ buf.append("mode= " + mode);
+ debugLogger.debug("11247 " + buf.toString());
+ }
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncCommand::getServerMode() out ");
+ debugLogger.debug("11248 " + buf.toString());
+ }
+ serverMode = mode;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+import java.net.*;
+import java.util.HashSet;
+import java.util.Vector;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.controller.DirectorController;
+import org.ultramonkey.l7.controller.DirectorData;
+import org.ultramonkey.l7.controller.L7vsConfController;
+import org.ultramonkey.l7.controller.L7vsConfData;
+import org.ultramonkey.l7.controller.LogSet;
+
+/**
+ * <p>class L7SyncManager</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author momose
+ */
+public class L7SyncManager {
+ protected Logger debugLogger = Logger.getLogger(LogCategorySet.SYNC_SYNC);
+
+ protected Logger debugDirectorLogger = Logger
+ .getLogger(LogCategorySet.SYNC_SYNC_DIRECTOR_DATA);
+
+ protected Logger debugL7vsdConfLogger = Logger
+ .getLogger(LogCategorySet.SYNC_SYNC_L7VSDCONF_DATA);
+
+ protected Logger debugUserLogger = Logger
+ .getLogger(LogCategorySet.SYNC_SYNC_USER_DATA);
+
+ protected String categoryName;
+
+ protected String actHost;
+
+ protected String sbyHost;
+
+ protected int sbyPort;
+
+ protected Logger logger = Logger.getLogger(LogCategorySet.SYNC_SYNC);
+
+ protected Logger directorLogger = Logger
+ .getLogger(LogCategorySet.SYNC_SYNC_DIRECTOR_DATA);
+
+ protected Logger l7vsdConfLogger = Logger
+ .getLogger(LogCategorySet.SYNC_SYNC_L7VSDCONF_DATA);
+
+ protected Logger userLogger = Logger.getLogger(LogCategorySet.SYNC_SYNC_USER_DATA);
+
+ protected enum SyncDataType {
+ DIRECTORDATA, L7VSCONFDATA, USERDATA
+ };
+
+ /**
+ * Constructor gets data from Parameter class
+ *
+ */
+ public L7SyncManager() {
+ // debug log(constructor)
+ if (debugLogger.isDebugEnabled()) {
+ debugLogger.debug("11058 class L7SyncManager created.");
+ }
+
+ Parameter parameter = Parameter.getInstance();
+ actHost = parameter.getValue("actHost");
+ sbyHost = parameter.getValue("sbyHost");
+ sbyPort = Integer.parseInt(parameter.getValue("sbyPort"));
+ }
+
+ /**
+ * <p> Active server sends synchronous data from active server to stand-by server. It recieves results from stand-by server.</p>
+ *
+ * @param categoryIdSet category IDs of synchronous data
+ * @throws MessageView
+ */
+ public void syncAct(HashSet<Integer> categoryIdSet) throws MessageView {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::syncAct(HashSet<Integer> categoryIdSet) throws MessageView in ");
+ buf.append("categoryIdSet= " + categoryIdSet.toString());
+ debugLogger.debug("11059 " + buf.toString());
+ }
+
+ Vector<Payload> payloadVec = new Vector<Payload>();
+ Payload payload = null;
+ L7SyncSocket l7SyncSocket = new L7SyncSocket();
+
+ for (int categoryId : categoryIdSet) {
+ switch (getDataTypeFromId(categoryId)) {
+ case DIRECTORDATA:
+ try {
+ DirectorController directorController = new DirectorController();
+ payload = new Payload(categoryId, directorController
+ .getDirectorData());
+ } catch (Exception e) {
+ logger.error("41007 " + Message.SYNC_SET_ERROR + "DirectorData : " + e);
+ throw new MessageView(40012, LogCategorySet.SYNC_START_STOP,
+ Message.SYNC_SET_ERROR + " DirectorData :" + e);
+ }
+ break;
+
+ case L7VSCONFDATA:
+ L7vsConfController l7vsConfController = new L7vsConfController();
+ try {
+ payload = new Payload(categoryId, l7vsConfController.getConfData());
+ } catch (FileNotReadException e) {
+ logger.error("41008 " + Message.SYNC_SET_ERROR + "L7vsConfData : " + e);
+ throw new MessageView(40013, LogCategorySet.SYNC_SYNC,
+ Message.SYNC_GET_ERROR + " L7vsConfData :" + e);
+ }
+ break;
+
+ case USERDATA:
+ try {
+ UserManager userManager = new UserManager();
+ payload = new Payload(categoryId, userManager.getUserList());
+ } catch (FileNotReadException e) {
+ logger.error("41009 " + Message.SYNC_SET_ERROR + "L7vsdConfData : " + e);
+ throw new MessageView(40030, LogCategorySet.SYNC_SYNC,
+ Message.SYNC_GET_ERROR + " UserData :" + e);
+ }
+ break;
+
+ default:
+ throw new MessageView(40027, LogCategorySet.SYNC_START_STOP,
+ Message.SYNC_INVALID_CATEGORY_ID);
+ }
+ payloadVec.add(payload);
+ }
+ try {
+ if (sbyHost == null)
+ throw new ConnectException();
+ Socket socket = new Socket(sbyHost, sbyPort);
+ l7SyncSocket
+ .openConnection(socket.getInputStream(), socket
+ .getOutputStream());
+ } catch (Exception e) {
+ logger.error("41010 " + Message.SYNC_OPEN_ERROR + " : " + e);
+ throw new MessageView(40014, LogCategorySet.SYNC_START_STOP,
+ Message.SYNC_OPEN_ERROR);
+ }
+ sendRecv(l7SyncSocket, payloadVec);
+
+ try {
+ l7SyncSocket.closeConnection();
+ } catch (MessageView m) {
+ logger.error("41011 " + m.message);
+ throw m;
+ }
+
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::syncAct(HashSet<Integer> categoryIdSet) throws MessageView out ");
+ debugLogger.debug("11060 " + buf.toString());
+ }
+
+ }
+
+ /**
+ * <p> Stand-by server recieves synchronous data from active server. It compares synchronous data. It updates stand-by data if there are any differences between active server settings and stand-by server settings.</p>
+ *
+ * @throws MessageView
+ */
+ public void syncSby() throws MessageView {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncManager::syncSby() throws MessageView in ");
+ debugLogger.debug("11061 " + buf.toString());
+ }
+
+ L7SyncSocket l7SyncSocket = new L7SyncSocket();
+ Payload recvPayload = null;
+ Payload sendPayload;
+ String[] recvData;
+ Object sbyData;
+
+ try {
+ l7SyncSocket.openConnection(System.in, System.out);
+ } catch (MessageView m) {
+ logger.error("41012 " + m.message);
+ throw m;
+ }
+
+ while (null != (recvData = l7SyncSocket.recvData())) {
+ try {
+ recvPayload = new Payload(recvData);
+ switch (getDataTypeFromId(recvPayload.categoryId)) {
+ case DIRECTORDATA:
+ DirectorController directorController = new DirectorController();
+ try {
+ DirectorData sbyDirectorData = compareDirectorData(recvPayload,
+ directorController.getDirectorData());
+ if (null != sbyDirectorData) {
+ directorController.setDirectorData(sbyDirectorData);
+ }
+ } catch (Exception e) {
+ throw new MessageView(40015, LogCategorySet.SYNC_START_STOP,
+ Message.SYNC_GET_ERROR + " DirectorData");
+ }
+ break;
+
+ case L7VSCONFDATA:
+ L7vsConfController l7vsConfController = new L7vsConfController();
+ try {
+ L7vsConfData sbyL7vsConfData = compareL7vsConfData(recvPayload,
+ l7vsConfController.getConfData());
+ if (null != sbyL7vsConfData) {
+ l7vsConfController.setConfData(sbyL7vsConfData);
+ }
+ } catch (FileNotReadException e) {
+ throw new MessageView(40016, LogCategorySet.SYNC_SYNC,
+ Message.SYNC_GET_ERROR + " L7vsConfData :" + e);
+ } catch (FileNotWriteException e) {
+ throw new MessageView(40017, LogCategorySet.SYNC_SYNC,
+ Message.SYNC_SET_ERROR + " L7vsConfData :" + e);
+ }
+ break;
+
+ case USERDATA:
+ try {
+ UserManager userManager = new UserManager();
+ Vector<UserData> sbyUserVec = compareUserData(recvPayload,
+ userManager.getUserList());
+ if (null != sbyUserVec) {
+ userManager.setUserList(sbyUserVec);
+ }
+ } catch (Exception e) {
+ throw new MessageView(40018, LogCategorySet.SYNC_START_STOP,
+ Message.SYNC_GET_ERROR + " userdata");
+ }
+ break;
+ default:
+ throw new MessageView(40028, LogCategorySet.SYNC_START_STOP,
+ Message.SYNC_INVALID_CATEGORY_ID);
+ }
+ sendPayload = new Payload(SyncCategoryIdSet.SYNC_OK, new DirectorData());
+ logger.info("21001 " + SyncCategoryIdSet.toCategoryName(recvPayload.categoryId)
+ + Message.SYNC_SUCCESS);
+
+ } catch (MessageView m) {
+ logger.error("41013 " + m.message);
+ sendPayload = new Payload(SyncCategoryIdSet.SYNC_NG, new DirectorData());
+ }
+
+ l7SyncSocket.sendData(sendPayload.getMessage());
+ }
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncManager::syncSby() throws MessageView out ");
+ debugLogger.debug("11062 " + buf.toString());
+ }
+
+ }
+
+ /**
+ * <p> Sends synchronous data and recieves results from stand-by server. </p>
+ *
+ * @param l7SyncSocket
+ * @param payloadVec synchronous data
+ * @throws MessageView
+ */
+ protected void sendRecv(L7SyncSocket l7SyncSocket, Vector<Payload> payloadVec)
+ throws MessageView {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::sendRecv(L7SyncSocket l7SyncSocket, Vector<Payload> payloadVec) throws MessageView in ");
+ buf.append("l7SyncSocket= " + l7SyncSocket.toString() + ", ");
+ buf.append("payloadVec= " + payloadVec.toString());
+ debugLogger.debug("11063 " + buf.toString());
+ }
+
+ Payload recvPayload;
+ for (Payload payload : payloadVec) {
+ l7SyncSocket.sendData(payload.getMessage());
+ recvPayload = new Payload(l7SyncSocket.recvData());
+ switch (recvPayload.categoryId) {
+ case SyncCategoryIdSet.SYNC_NG:
+ logger.error("41014 " + Message.SYNC_FAIL + " : "
+ + SyncCategoryIdSet.toCategoryName(payload.categoryId));
+ throw new MessageView(
+ 40019,
+ LogCategorySet.SYNC_CONNECTION,
+ Message.SYNC_FAIL
+ + " : "
+ + SyncCategoryIdSet
+ .toCategoryName(payload.categoryId));
+ case SyncCategoryIdSet.SYNC_OK:
+ logger.info("21002 " + SyncCategoryIdSet.toCategoryName(payload.categoryId)
+ + Message.SYNC_SUCCESS);
+ break;
+ default:
+ throw new MessageView(40029, LogCategorySet.SYNC_START_STOP,
+ Message.SYNC_INVALID_CATEGORY_ID);
+ }
+ }
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::sendRecv(L7SyncSocket l7SyncSocket, Vector<Payload> payloadVec) throws MessageView out ");
+ debugLogger.debug("11064 " + buf.toString());
+ }
+
+ }
+
+ /**
+ * <p> Compares DirectorData settings in active server with those in stand-by server. Updates DirectorData in stand-by server if there are any differences between them.</p>
+ *
+ * @param categoryId category ID of synchronous data
+ * @param recvData recieve data from active server
+ * @throws MessageView
+ */
+ protected DirectorData compareDirectorData(Payload recvData,
+ DirectorData sbyDirectorData) throws MessageView {
+ // debug log(in method)
+ if (debugDirectorLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::compareDirectorData(Payload recvData, DirectorData sbyDirectorData) throws MessageView in ");
+ buf.append("recvData= " + recvData.toString() + ", ");
+ buf.append("sbyDirectorData= " + sbyDirectorData.toString());
+ debugDirectorLogger.debug("11065 " + buf.toString());
+ }
+
+ DirectorData actDirectorData = recvData.getDirectorData();
+ boolean needSync = false;
+
+ switch (recvData.categoryId) {
+ case SyncCategoryIdSet.MONITOR_ID:
+ if (actDirectorData.checkTimeOut != sbyDirectorData.checkTimeOut) {
+ directorLogger.info("21003 " + Message.SYNC_DIFFERENT_DATA + " : checkTimeOut ");
+ sbyDirectorData.checkTimeOut = actDirectorData.checkTimeOut;
+ needSync = true;
+ }
+ if (actDirectorData.negotiateTimeOut != sbyDirectorData.negotiateTimeOut) {
+ directorLogger.info("21004 " + Message.SYNC_DIFFERENT_DATA + " : negotiateTimeOut ");
+ sbyDirectorData.negotiateTimeOut = actDirectorData.negotiateTimeOut;
+ needSync = true;
+ }
+ if (actDirectorData.checkInterval != sbyDirectorData.checkInterval) {
+ directorLogger.info("21005 " + Message.SYNC_DIFFERENT_DATA + " : checkInterval ");
+ sbyDirectorData.checkInterval = actDirectorData.checkInterval;
+ needSync = true;
+ }
+ if (actDirectorData.checkCount != sbyDirectorData.checkCount) {
+ directorLogger.info("21006 " + Message.SYNC_DIFFERENT_DATA + " : checkCount ");
+ sbyDirectorData.checkCount = actDirectorData.checkCount;
+ needSync = true;
+ }
+ if (actDirectorData.autoreload != sbyDirectorData.autoreload) {
+ directorLogger.info("21007 " + Message.SYNC_DIFFERENT_DATA + " : autoreload ");
+ sbyDirectorData.autoreload = actDirectorData.autoreload;
+ needSync = true;
+ }
+ if (!actDirectorData.callback.equals(sbyDirectorData.callback)) {
+ directorLogger.info("21008 " + Message.SYNC_DIFFERENT_DATA + " : callback ");
+ sbyDirectorData.callback = actDirectorData.callback;
+ needSync = true;
+ }
+ if (!actDirectorData.fallback.equals(sbyDirectorData.fallback)) {
+ directorLogger.info("21009 " + Message.SYNC_DIFFERENT_DATA + " : fallback ");
+ sbyDirectorData.fallback = actDirectorData.fallback;
+ needSync = true;
+ }
+ if (!actDirectorData.logfile.equals(sbyDirectorData.logfile)) {
+ directorLogger.info("21010 " + Message.SYNC_DIFFERENT_DATA + " : logfile ");
+ sbyDirectorData.logfile = actDirectorData.logfile;
+ needSync = true;
+ }
+ if (!actDirectorData.execute.equals(sbyDirectorData.execute)) {
+ directorLogger.info("21011 " + Message.SYNC_DIFFERENT_DATA + " : execute ");
+ sbyDirectorData.execute = actDirectorData.execute;
+ needSync = true;
+ }
+ if (!actDirectorData.supervised.equals(sbyDirectorData.supervised)) {
+ directorLogger.info("21012 " + Message.SYNC_DIFFERENT_DATA + " : supervised ");
+ sbyDirectorData.supervised = actDirectorData.supervised;
+ needSync = true;
+ }
+ if (!actDirectorData.quiescent.equals(sbyDirectorData.quiescent)) {
+ directorLogger.info("21013 " + Message.SYNC_DIFFERENT_DATA + " : quiescent ");
+ sbyDirectorData.quiescent = actDirectorData.quiescent;
+ needSync = true;
+ }
+ break;
+
+ case SyncCategoryIdSet.SERVICE_ID:
+ if (actDirectorData.virtualSettings.size() != sbyDirectorData.virtualSettings
+ .size()) {
+ sbyDirectorData.virtualSettings = actDirectorData.virtualSettings;
+ directorLogger.info("21014 " + Message.SYNC_DIFFERENT_DATA + " : virtualSettings ");
+ needSync = true;
+ } else {
+ if (!actDirectorData.virtualSettings
+ .equals(sbyDirectorData.virtualSettings)) {
+ sbyDirectorData.virtualSettings = actDirectorData.virtualSettings;
+ needSync = true;
+ }
+ }
+ break;
+
+ default:
+ throw new MessageView(40020, LogCategorySet.SYNC_SYNC_DIRECTOR_DATA,
+ Message.SYNC_INVALID_CATEGORY_ID);
+ }
+ if (!needSync) {
+ directorLogger.info("21015 " + Message.SYNC_SAME_DATA + " : "
+ + SyncCategoryIdSet.toCategoryName(recvData.categoryId));
+
+ // debug log(out method)
+ if (debugDirectorLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::compareDirectorData(Payload recvData, DirectorData sbyDirectorData) throws MessageView out ");
+ buf.append("return= null");
+ debugDirectorLogger.debug("11066 " + buf.toString());
+ }
+ return null;
+ }
+
+ // debug log(out method)
+ if (debugDirectorLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::compareDirectorData(Payload recvData, DirectorData sbyDirectorData) throws MessageView out ");
+ buf.append("return= " + sbyDirectorData.toString());
+ debugDirectorLogger.debug("11067 " + buf.toString());
+ }
+
+ return sbyDirectorData;
+ }
+
+ /**
+ * <p> Compares UserData settings in active server with those in stand-by server. Updates UserData in stand-by server if there are any differences between them.</p>
+ *
+ * @param categoryId category id of synchronous data
+ * @param recvData recieve data from active server
+ * @throws MessageView
+ */
+ protected Vector<UserData> compareUserData(Payload recvData,
+ Vector<UserData> sbyUserVec) throws MessageView {
+ // debug log(in method)
+ if (debugUserLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::compareUserData(Payload recvData, Vector<UserData> sbyUserVec) throws MessageView in ");
+ buf.append("recvData= " + recvData.toString() + ", ");
+ buf.append("sbyUserVec= " + sbyUserVec.toString());
+ debugUserLogger.debug("11068 " + buf.toString());
+ }
+
+ if (SyncCategoryIdSet.USERDATA_ID != recvData.categoryId) {
+ throw new MessageView(40021, LogCategorySet.SYNC_SYNC_USER_DATA,
+ Message.SYNC_INVALID_CATEGORY_ID);
+ }
+
+ Vector<UserData> actUserVec = recvData.getUserData();
+
+ if (actUserVec.size() != sbyUserVec.size() || !actUserVec.equals(sbyUserVec)) {
+ userLogger.info("21016 " + Message.SYNC_DIFFERENT_DATA + " : "
+ + SyncCategoryIdSet.toCategoryName(recvData.categoryId));
+
+ // debug log(out method)
+ if (debugUserLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::compareUserData(Payload recvData, Vector<UserData> sbyUserVec) throws MessageView out ");
+ buf.append("return= " + actUserVec.toString());
+ debugUserLogger.debug("11069 " + buf.toString());
+ }
+
+ return actUserVec;
+ } else {
+ userLogger.info("21017 " + Message.SYNC_SAME_DATA + " : "
+ + SyncCategoryIdSet.toCategoryName(recvData.categoryId));
+
+ // debug log(out method)
+ if (debugUserLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::compareUserData(Payload recvData, Vector<UserData> sbyUserVec) throws MessageView out ");
+ buf.append("return= null");
+ debugUserLogger.debug("11070 " + buf.toString());
+ }
+
+ return null;
+ }
+ }
+
+ /**
+ * <p> Compares L7vsConfData settings in active server with those in stand-by server. Updates L7vsConfData in stand-by server if there are any differences between them.</p>
+ *
+ * @param categoryId category ID of synchronous data
+ * @param recvData recieve data from active server
+ * @throws MessageView
+ */
+ protected L7vsConfData compareL7vsConfData(Payload recvData,
+ L7vsConfData sbyL7vsdConfData) throws MessageView {
+ // debug log(in method)
+ if (debugL7vsdConfLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::compareL7vsConfData(Payload recvData, L7vsConfData sbyL7vsdConfData) throws MessageView in ");
+ buf.append("recvData= " + recvData.toString() + ", ");
+ buf.append("sbyL7vsdConfData= " + sbyL7vsdConfData.toString());
+ debugL7vsdConfLogger.debug("11071 " + buf.toString());
+ }
+
+ L7vsConfData actL7vsdConfData = recvData.getL7vsdConfData();
+ boolean needSync = false;
+ L7vsConfController confController = new L7vsConfController();
+
+ switch (recvData.categoryId) {
+ case SyncCategoryIdSet.L7VSD_LOG_ID:
+ needSync = compareLogSettings(actL7vsdConfData.logger.lbLog,
+ sbyL7vsdConfData.logger.lbLog);
+ if (needSync) {
+ sbyL7vsdConfData.logger.lbLog = actL7vsdConfData.logger.lbLog;
+ }
+ break;
+
+ case SyncCategoryIdSet.ADM_LOG_ID:
+ needSync = compareLogSettings(actL7vsdConfData.logger.admLog,
+ sbyL7vsdConfData.logger.admLog);
+ if (needSync) {
+ sbyL7vsdConfData.logger.admLog = actL7vsdConfData.logger.admLog;
+ }
+ break;
+
+ case SyncCategoryIdSet.SNMP_LOG_ID:
+ needSync = compareLogSettings(actL7vsdConfData.logger.snmpLog,
+ sbyL7vsdConfData.logger.snmpLog);
+ if (needSync) {
+ sbyL7vsdConfData.logger.snmpLog = actL7vsdConfData.logger.snmpLog;
+ }
+ break;
+
+ case SyncCategoryIdSet.LOG_ALL_ID:
+ boolean lbLogFlg = compareLogSettings(actL7vsdConfData.logger.lbLog,
+ sbyL7vsdConfData.logger.lbLog);
+ boolean admLogFlg = compareLogSettings(actL7vsdConfData.logger.admLog,
+ sbyL7vsdConfData.logger.admLog);
+ boolean snmpLogFlg = compareLogSettings(actL7vsdConfData.logger.snmpLog,
+ sbyL7vsdConfData.logger.snmpLog);
+
+ needSync = lbLogFlg || admLogFlg || snmpLogFlg;
+
+ if (needSync) {
+ sbyL7vsdConfData.logger.lbLog = actL7vsdConfData.logger.lbLog;
+ sbyL7vsdConfData.logger.admLog = actL7vsdConfData.logger.admLog;
+ sbyL7vsdConfData.logger.snmpLog = actL7vsdConfData.logger.snmpLog;
+ }
+ break;
+
+ case SyncCategoryIdSet.REPLICATION_INFO_ID:
+ if (actL7vsdConfData.replicationInterval != sbyL7vsdConfData.replicationInterval) {
+ logger.info("21018 " + Message.SYNC_DIFFERENT_DATA + ": Replication");
+ sbyL7vsdConfData.replicationInterval = actL7vsdConfData.replicationInterval;
+ needSync = true;
+ }
+ break;
+
+ case SyncCategoryIdSet.SNMP_INFO_ID:
+ if (actL7vsdConfData.snmpInterval != sbyL7vsdConfData.snmpInterval) {
+ logger.info("21019 " + Message.SYNC_DIFFERENT_DATA + ": snmpInterval");
+ sbyL7vsdConfData.snmpInterval = actL7vsdConfData.snmpInterval;
+ needSync = true;
+ }
+ break;
+
+ case SyncCategoryIdSet.ADM_INFO_ID:
+ if (actL7vsdConfData.admCmdInterval != sbyL7vsdConfData.admCmdInterval) {
+ logger.info("21020 " + Message.SYNC_DIFFERENT_DATA + ": admCmdInterval");
+ sbyL7vsdConfData.admCmdInterval = actL7vsdConfData.admCmdInterval;
+ needSync = true;
+ }
+ if (actL7vsdConfData.admCmdCount != sbyL7vsdConfData.admCmdCount) {
+ logger.info("21021 " + Message.SYNC_DIFFERENT_DATA + ": admCmdCount");
+ sbyL7vsdConfData.admCmdCount = actL7vsdConfData.admCmdCount;
+ needSync = true;
+ }
+ if (actL7vsdConfData.admConInterval != sbyL7vsdConfData.admConInterval) {
+ logger.info("21022 " + Message.SYNC_DIFFERENT_DATA + ": admConInterval");
+ sbyL7vsdConfData.admConInterval = actL7vsdConfData.admConInterval;
+ needSync = true;
+ }
+ if (actL7vsdConfData.admConCount != sbyL7vsdConfData.admConCount) {
+ logger.info("21023 " + Message.SYNC_DIFFERENT_DATA + ": admConCount");
+ sbyL7vsdConfData.admConCount = actL7vsdConfData.admConCount;
+ needSync = true;
+ }
+ break;
+
+ default:
+ l7vsdConfLogger.error("41015 " + Message.SYNC_INVALID_CATEGORY_ID);
+ throw new MessageView(40022, LogCategorySet.SYNC_SYNC_L7VSDCONF_DATA,
+ Message.SYNC_INVALID_CATEGORY_ID);
+ }
+
+ if (!needSync) {
+ l7vsdConfLogger.info("21024 " + Message.SYNC_SAME_DATA + " : "
+ + SyncCategoryIdSet.toCategoryName(recvData.categoryId));
+ if (debugL7vsdConfLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::compareL7vsConfData(Payload recvData, L7vsConfData sbyL7vsdConfData) throws MessageView out ");
+ buf.append("return= null");
+ debugL7vsdConfLogger.debug("11072 " + buf.toString());
+ }
+ return null;
+
+ } else {
+ // debug log(out method)
+ if (debugL7vsdConfLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::compareL7vsConfData(Payload recvData, L7vsConfData sbyL7vsdConfData) throws MessageView out ");
+ buf.append("return= " + sbyL7vsdConfData.toString());
+ debugL7vsdConfLogger.debug("11073 " + buf.toString());
+ }
+
+ return sbyL7vsdConfData;
+ }
+ }
+
+ /**
+ * <p> Gets synchronous data class from category ID.</p>
+ *
+ * @param categoryId category ID of synchronous data
+ * @return data class name of synchronous data
+ * @throws MessageView
+ */
+ protected SyncDataType getDataTypeFromId(int categoryId) throws MessageView {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::getDataTypeFromId(int categoryId) throws MessageView in ");
+ buf.append("categoryId=" + categoryId);
+ debugLogger.debug("11074 " + buf.toString());
+ }
+
+ switch (categoryId) {
+ case SyncCategoryIdSet.MONITOR_ID:
+ case SyncCategoryIdSet.SERVICE_ID:
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::getDataTypeFromId(int categoryId) throws MessageView out ");
+ buf.append("return= SyncDataType.DIRECTORDATA");
+ debugLogger.debug("11075 " + buf.toString());
+ }
+ return SyncDataType.DIRECTORDATA;
+
+ case SyncCategoryIdSet.L7VSD_LOG_ID:
+ case SyncCategoryIdSet.ADM_LOG_ID:
+ case SyncCategoryIdSet.SNMP_LOG_ID:
+ case SyncCategoryIdSet.REPLICATION_INFO_ID:
+ case SyncCategoryIdSet.ADM_INFO_ID:
+ case SyncCategoryIdSet.SNMP_INFO_ID:
+ case SyncCategoryIdSet.LOG_ALL_ID:
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::getDataTypeFromId(int categoryId) throws MessageView out ");
+ buf.append("return= SyncDataType.L7VSCONFDATA");
+ debugLogger.debug("11076 " + buf.toString());
+ }
+ return SyncDataType.L7VSCONFDATA;
+
+ case SyncCategoryIdSet.USERDATA_ID:
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::getDataTypeFromId(int categoryId) throws MessageView out ");
+ buf.append("return= SyncDataType.USERDATA");
+ debugLogger.debug("11077 " + buf.toString());
+ }
+ return SyncDataType.USERDATA;
+
+ default:
+ throw new MessageView(40023, LogCategorySet.SYNC_SYNC,
+ Message.SYNC_INVALID_CATEGORY_ID);
+ }
+ }
+
+ /**
+ * <p> Compares log settings in active server with those in stand-by server. </p>
+ *
+ * @param actLogger LogSet of active server
+ * @param sbyLogger LogSet of stand-by server
+ * @return sync flag
+ */
+ protected boolean compareLogSettings(LogSet actLogger, LogSet sbyLogger) {
+ // debug log(in method)
+ if (debugL7vsdConfLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::compareLogSettings(LogSet actLogger, LogSet sbyLogger) in ");
+ buf.append("actLogger= " + actLogger.toString() + ", ");
+ buf.append("sbyLogger= " + sbyLogger.toString());
+ debugL7vsdConfLogger.debug("11078 " + buf.toString());
+ }
+
+ boolean syncFlag = false;
+ if (!actLogger.logLevel.equals(sbyLogger.logLevel)) {
+ l7vsdConfLogger.info("21025 " + Message.SYNC_DIFFERENT_DATA + " : LogLevel ");
+ syncFlag = true;
+ }
+ if (!actLogger.maxFileSize.equals(sbyLogger.maxFileSize)) {
+ l7vsdConfLogger.info("21026 " + Message.SYNC_DIFFERENT_DATA + " : maxFileSize ");
+ syncFlag = true;
+ }
+ if (actLogger.maxBackupIndex != sbyLogger.maxBackupIndex) {
+ l7vsdConfLogger.info("21027 " + Message.SYNC_DIFFERENT_DATA + " : maxBackupIndex ");
+ syncFlag = true;
+ }
+ if (!actLogger.fileName.equals(sbyLogger.fileName)) {
+ l7vsdConfLogger.info("21028 " + Message.SYNC_DIFFERENT_DATA + " : fileName ");
+ syncFlag = true;
+ }
+ if (!actLogger.rotation.equals(sbyLogger.rotation)) {
+ l7vsdConfLogger.info("21029 " + Message.SYNC_DIFFERENT_DATA + " : rotation ");
+ syncFlag = true;
+ }
+ // debug log(out method)
+ if (debugL7vsdConfLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("L7SyncManager::compareLogSettings(LogSet actLogger, LogSet sbyLogger) out ");
+ buf.append("return= " + syncFlag);
+ debugL7vsdConfLogger.debug("11079 " + buf.toString());
+ }
+
+ return syncFlag;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+
+import org.apache.log4j.Logger;
+
+/**
+ * <p>
+ * class L7SyncSocket
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author momose
+ */
+public class L7SyncSocket {
+ protected Logger debugLogger = Logger
+ .getLogger(LogCategorySet.SYNC_CONNECTION);
+
+ protected OutputStream outputStream;
+
+ protected InputStream inputStream;
+
+ protected BufferedReader bufferedReader;
+
+ protected BufferedWriter bufferedWriter;
+
+ protected final String SEPARATOR = "\r\n";
+
+ protected final int ENTRY_NUMBER = 3;
+
+ /**
+ * Constructor
+ *
+ */
+ public L7SyncSocket() {
+ // debug log(constructor)
+ if (debugLogger.isDebugEnabled()) {
+ debugLogger.debug("11221 class L7SyncSocket created.");
+ }
+ }
+
+ /**
+ * <p>
+ * Sets inputStream and outputastream which got at L7SyncManager.
+ * </p>
+ *
+ * @param inputStream
+ * @param outputStream
+ * @throws MessageView
+ */
+ public void openConnection(InputStream inputStream,
+ OutputStream outputStream) throws MessageView {
+
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncSocket::openConnection(InputStream inputStream, OutputStream outputStream) throws MessageView in ");
+
+ if (null != inputStream) {
+ buf.append("inputStream= " + inputStream.toString() + ", ");
+ } else {
+ buf.append("inputStream= " + "null, ");
+ }
+ if (null != outputStream) {
+ buf.append("outputStream= " + outputStream.toString());
+ } else {
+ buf.append("outputStream= " + "null");
+ }
+ debugLogger.debug("11222 " + buf.toString());
+ }
+
+ if ((null == inputStream) || (null == outputStream)) {
+ throw new MessageView(40009, LogCategorySet.SYNC_CONNECTION,
+ Message.SYNC_INVALID_ARGUMENT + " OpenConnection : null");
+ }
+
+ this.inputStream = inputStream;
+ this.outputStream = outputStream;
+
+ bufferedWriter = new BufferedWriter(new OutputStreamWriter(
+ this.outputStream));
+
+ bufferedReader = new BufferedReader(new InputStreamReader(
+ this.inputStream));
+
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncSocket::openConnection(InputStream inputStream, OutputStream outputStream) throws MessageView out ");
+ debugLogger.debug("11223 " + buf.toString());
+ }
+
+ }
+
+ /**
+ * <p>
+ * Sends data.
+ * </p>
+ *
+ * @param payloadStr
+ * recieve data
+ * @throws MessageView
+ */
+ public void sendData(String[] payloadStr) throws MessageView {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncSocket::sendData(String[] payloadStr) throws MessageView in ");
+ buf.append("payloadStr= ");
+ if (null == payloadStr) {
+ buf.append("null");
+ } else {
+ for (int i = 0; i < payloadStr.length; i++) {
+ if (payloadStr.length - 1 == i) {
+ buf.append(payloadStr[i].toString());
+ break;
+ }
+ buf.append(payloadStr[i].toString() + ",");
+ }
+ }
+ debugLogger.debug("11224 " + buf.toString());
+ }
+
+ if (null == payloadStr) {
+ throw new MessageView(40010, LogCategorySet.SYNC_CONNECTION,
+ Message.SYNC_INVALID_ARGUMENT + " SendData : " + payloadStr);
+ }
+ try {
+ for (int i = 0; i < payloadStr.length; i++) {
+ bufferedWriter.write(payloadStr[i]);
+ bufferedWriter.write(SEPARATOR);
+ }
+ bufferedWriter.write(SEPARATOR);
+ bufferedWriter.flush();
+ } catch (Exception e) {
+ throw new MessageView(50001, LogCategorySet.SYNC_CONNECTION,
+ Message.SYNC_SEND_ERROR + " : " + e);
+ }
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncSocket::sendData(String[] payloadStr) throws MessageView out ");
+ debugLogger.debug("11225 " + buf.toString());
+ }
+ }
+
+ /**
+ * <p>
+ * Recieves data.
+ * </p>
+ *
+ * @return buffer send data
+ * @throws MessageView
+ */
+ public String[] recvData() throws MessageView {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncSocket::recvData() throws MessageView in ");
+ debugLogger.debug("11226 " + buf.toString());
+ }
+
+ String readStr;
+ String[] readDataArray = null;
+
+ try {
+ readDataArray = new String[ENTRY_NUMBER];
+ int i = 0;
+ while (true) {
+ readStr = bufferedReader.readLine();
+ if (null == readStr) {
+ return null;
+ }
+
+ if ((0 == readStr.length())) {
+ break;
+ }
+ if (i >= ENTRY_NUMBER) {
+ throw new MessageView(40011,
+ LogCategorySet.SYNC_CONNECTION,
+ Message.SYNC_INVALID_RECV_DATA);
+ }
+ readDataArray[i] = readStr;
+ i++;
+ }
+ } catch (Exception e) {
+ throw new MessageView(50002, LogCategorySet.SYNC_CONNECTION,
+ Message.SYNC_RECV_ERROR + " : " + e);
+ }
+
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncSocket::recvData() throws MessageView out ");
+ buf.append("return= ");
+ if (0 == readDataArray.length) {
+ buf.append("null");
+ } else {
+ for (int i = 0; i < readDataArray.length; i++) {
+ if (readDataArray.length - 1 == i) {
+ buf.append(readDataArray[i].toString());
+ break;
+ }
+ buf.append(readDataArray[i].toString() + ",");
+ }
+ }
+ debugLogger.debug("11227 " + buf.toString());
+ }
+ return readDataArray;
+ }
+
+ /**
+ * <p>
+ * Active server closes connection after recieving all results from stand-by
+ * server.
+ * </p>
+ *
+ * @throws MessageView
+ */
+ public void closeConnection() throws MessageView {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncSocket::closeConnection() throws MessageView in ");
+ debugLogger.debug("11228 " + buf.toString());
+ }
+ try {
+ outputStream.close();
+ } catch (Exception e) {
+ throw new MessageView(50003, LogCategorySet.SYNC_CONNECTION,
+ Message.SYNC_CLOSE_ERROR + " :" + e);
+ }
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7SyncSocket::closeConnection() throws MessageView out ");
+ debugLogger.debug("11229 " + buf.toString());
+ }
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.controller.*;
+
+/**
+ *
+ * <p>
+ * class L7guiFramework
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author tanuma
+ */
+public class L7guiFramework {
+
+ private Logger ioCommandLogger = Logger.getLogger(LogCategorySet.GUI_IO_COMMAND);
+ private Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE);
+ private Logger saveLogger = Logger.getLogger(LogCategorySet.GUI_SAVE);
+ private Logger syncLogger = Logger.getLogger(LogCategorySet.GUI_SYNC);
+ private Logger repLogger = Logger.getLogger(LogCategorySet.GUI_REPLICATION);
+ private Logger snmpLogger = Logger.getLogger(LogCategorySet.GUI_SNMP);
+
+ /**
+ *
+ * <p>
+ * addVirtualSetting method
+ * </p>
+ *
+ * @param vs
+ * virtual service to be added to l7vsd.
+ * @return result of l7vsadm add virtual service command command.
+ */
+ public boolean addVirtualSetting(VirtualSetting vs) {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11101 L7guiFramework::addVirtualSetting(VirtualSetting vs) in vs=(" + vs + ")");
+ }
+ // --- debug log (in method) ---
+
+ L7vsAdmController admController = new L7vsAdmController();
+ boolean ret = admController.addVirtualService(vs);
+
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11102 L7guiFramework::addVirtualSetting(VirtualSetting vs) out return=" + ret);
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * delVirtualSetting method
+ * </p>
+ *
+ * @param vs
+ * virtual service to be removed from l7vsd.
+ * @return result of l7vsadm delete virtual service command.
+ */
+ public boolean delVirtualSetting(VirtualSetting vs) {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11103 L7guiFramework::delVirtualSetting(VirtualSetting vs) in vs=(" + vs + ")");
+ }
+ // --- debug log (in method) ---
+
+ L7vsAdmController admController = new L7vsAdmController();
+ boolean ret = admController.delVirtualService(vs);
+
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11104 L7guiFramework::delVirtualSetting(VirtualSetting vs) out return=" + ret);
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * getAdmData method
+ * </p>
+ *
+ * @return result of l7vsadm list command, including virtual service
+ * setting.
+ */
+ public L7vsAdmData getAdmData() {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11105 L7guiFramework::getAdmData() in");
+ }
+ // --- debug log (in method) ---
+
+ L7vsAdmController admController = new L7vsAdmController();
+ L7vsAdmData ret = admController.getData();
+
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11106 L7guiFramework::getAdmData() out return=(" + ret + ")");
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * reloadAdmData method
+ * </p>
+ *
+ * @param category
+ * @return result of l7vsadm reload config.
+ */
+ public boolean reloadAdmData(L7vsConfCategory category) {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11107 L7guiFramework::reloadAdmData() in category=" + category);
+ }
+ // --- debug log (in method) ---
+
+ L7vsAdmController admController = new L7vsAdmController();
+ boolean ret = admController.reloadConf(category);
+
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11108 L7guiFramework::reloadAdmData() out return=" + ret);
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * getClusterData method
+ * </p>
+ *
+ * @return cluster data.
+ */
+ public ClusterData getClusterData() {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11109 L7guiFramework::getClusterData() in");
+ }
+ // --- debug log (in method) ---
+
+ ClusterController cluster = new ClusterController();
+ ClusterData ret = cluster.getData();
+
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11110 L7guiFramework::getClusterData() out return=(" + ret + ")");
+ }
+ // --- debug log (in method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * setClusterData method
+ * </p>
+ *
+ * @param c
+ */
+ public void setClusterData(ClusterData c) {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11111 L7guiFramework::setClusterData(ClusterData c) in c=(" + c + ")");
+ }
+ // --- debug log (in method) ---
+
+ ClusterController cluster = new ClusterController();
+ cluster.setData(c);
+
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11112 L7guiFramework::setClusterData(ClusterData c) out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ /**
+ *
+ * <p>
+ * setClusterMode method
+ * </p>
+ *
+ * @param mode
+ * @return result of switch over.
+ */
+ public boolean setClusterMode() {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11113 L7guiFramework::setClusterMode() in");
+ }
+ // --- debug log (in method) ---
+
+ ClusterController cluster = new ClusterController();
+ boolean ret = cluster.changeClusterMode();
+
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11114 L7guiFramework::setClusterMode() out return=" + ret);
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * getDirectorData method
+ * </p>
+ *
+ * @return l7directord.cf data.
+ */
+ public DirectorData getDirectorData() {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11115 L7guiFramework::getDirectorData() in");
+ }
+ // --- debug log (in method) ---
+
+ DirectorData d = null;
+ DirectorController directord = new DirectorController();
+ try {
+ d = directord.getDirectorData();
+ } catch (Exception e) {
+ ioFileLogger.error("41016 Exception occured: " + e.getMessage());
+ }
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11116 L7guiFramework::getDirectorData() out return=(" + d + ")");
+ }
+ // --- debug log (out method) ---
+ return d;
+ }
+
+ /**
+ *
+ * <p>
+ * setDirectorData method
+ * </p>
+ *
+ * @param d
+ * @return result of save l7directord.cf.
+ */
+ public boolean setDirectorData(DirectorData d) {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11117 L7guiFramework::setDirectorData(DirectorData d) in d=(" + d + ")");
+ }
+ // --- debug log (in method) ---
+
+ boolean ret = true;
+
+ DirectorController directord = new DirectorController();
+ try {
+ directord.setDirectorData(d);
+ } catch (FileNotWriteException e) {
+ ioFileLogger.error("41017 Exception occured: " + e.getMessage());
+ ret = false;
+ } catch (Exception e) {
+ ioFileLogger.error("41018 Exception occured: " + e.getMessage());
+ ret = false;
+ }
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11118 L7guiFramework::setDirectorData() out return=" + ret);
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * checkDirectorData method
+ * </p>
+ *
+ * @param d
+ * @return result of check l7directord.cf.
+ */
+ public String checkDirectorData(DirectorData d) {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11119 L7guiFramework::checkDirectorData(DirectorData d) in d=(" + d + ")");
+ }
+ // --- debug log (in method) ---
+
+ String result = null;
+ DirectorController directord = new DirectorController();
+ try {
+ result = directord.checkDirectorData(d);
+ } catch (FileNotWriteException e) {
+ ioFileLogger.error("41019 Exception occured: " + e.getMessage());
+ } catch (Exception e) {
+ ioFileLogger.error("41020 Exception occured: " + e.getMessage());
+ }
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11120 L7guiFramework::setDirectorData() out return=\"" + result + "\"");
+ }
+ // --- debug log (out method) ---
+ return result;
+ }
+
+ /**
+ *
+ * <p>
+ * getReplicationData method
+ * </p>
+ *
+ * @return replication setting data.
+ */
+ public ReplicationData getReplicationData() {
+ // --- debug log (in method) ---
+ if (repLogger.isDebugEnabled()) {
+ repLogger.debug("11121 L7guiFramework::getReplicationData() in");
+ }
+ // --- debug log (in method) ---
+
+ ReplicationData replicationData = new ReplicationData();
+
+ L7vsAdmController admController = new L7vsAdmController();
+ L7vsAdmData admData = admController.getData();
+ L7vsConfController confController = new L7vsConfController();
+ try {
+ L7vsConfData confData = confController.getConfData();
+
+ replicationData.interval = confData.replicationInterval;
+ replicationData.otherNode = confData.replicationOtherNode;
+ replicationData.component = confData.component;
+ replicationData.nic = confData.replicationNic;
+ replicationData.replicationMode = admData.replicationMode;
+ } catch (FileNotReadException e) {
+ ioFileLogger.error("41021 Exception occured: " + e.getMessage());
+ replicationData = null;
+ } catch (NullPointerException e) {
+ ioFileLogger.error("41022 Exception occured: " + e.getMessage());
+ replicationData = null;
+ } catch (Exception e) {
+ ioFileLogger.error("41023 Exception occured: " + e.getMessage());
+ replicationData = null;
+ }
+
+ // --- debug log (out method) ---
+ if (repLogger.isDebugEnabled()) {
+ repLogger.debug("11122 L7guiFramework::getReplicationData() out return=(" + replicationData + ")");
+ }
+ // --- debug log (out method) ---
+ return replicationData;
+ }
+
+ /**
+ *
+ * <p>
+ * setReplicationData method
+ * </p>
+ *
+ * @param r
+ * @return result of save l7vs.cf.
+ */
+ public boolean setReplicationData(ReplicationData r) {
+ // --- debug log (in method) ---
+ if (repLogger.isDebugEnabled()) {
+ repLogger.debug("11123 L7guiFramework::setReplicationData(ReplicationData r) in r=(" + r + ")");
+ }
+ // --- debug log (in method) ---
+
+ boolean ret = true;
+ L7vsConfController confController = new L7vsConfController();
+ try {
+ L7vsConfData cf = confController.getConfData();
+ cf.replicationInterval = r.interval;
+ confController.setConfData(cf);
+ } catch (FileNotReadException e) {
+ ioFileLogger.error("41024 Exception occured: " + e.getMessage());
+ ret = false;
+ } catch (FileNotWriteException e) {
+ ioFileLogger.error("41025 Exception occured: " + e.getMessage());
+ ret = false;
+ } catch (NullPointerException e) {
+ ioFileLogger.error("41026 Exception occured: " + e.getMessage());
+ ret = false;
+ } catch (Exception e) {
+ ioFileLogger.error("41027 Exception occured: " + e.getMessage());
+ ret = false;
+ }
+
+ // --- debug log (out method) ---
+ if (repLogger.isDebugEnabled()) {
+ repLogger.debug("11124 L7guiFramework::setReplicationData(ReplicationData r) out return=" + ret);
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * setReplicationMode method
+ * </p>
+ *
+ * @param mode
+ * @return result of l7vsadm change replication mode command.
+ */
+ public boolean setReplicationMode(ReplicationStatus mode) {
+ // --- debug log (in method) ---
+ if (repLogger.isDebugEnabled()) {
+ repLogger.debug("11125 L7guiFramework::setReplicationMode(ReplicationStatus mode) in mode=" + mode);
+ }
+ // --- debug log (in method) ---
+
+ L7vsAdmController admController = new L7vsAdmController();
+ boolean ret = admController.setReplicationMode(mode);
+
+ // --- debug log (out method) ---
+ if (repLogger.isDebugEnabled()) {
+ repLogger.debug("11126 L7guiFramework::setReplicationMode(ReplicationStatus mode) out return=" + ret);
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * dumpReplicationData method
+ * </p>
+ *
+ * @return result of l7vsadm replication dump command.
+ */
+ public boolean dumpReplicationData() {
+ // --- debug log (in method) ---
+ if (repLogger.isDebugEnabled()) {
+ repLogger.debug("11127 L7guiFramework::dumpReplicationData() in");
+ }
+ // --- debug log (in method) ---
+
+ L7vsAdmController admController = new L7vsAdmController();
+ boolean ret = admController.dumpReplicationData();
+
+ // --- debug log (out method) ---
+ if (repLogger.isDebugEnabled()) {
+ repLogger.debug("11128 L7guiFramework::dumpReplicationData() out return=" + ret);
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * getSnmpAgentData method
+ * </p>
+ *
+ * @return SNMP agent data.
+ */
+ public SnmpAgentData getSnmpAgentData() {
+ // --- debug log (in method) ---
+ if (snmpLogger.isDebugEnabled()) {
+ snmpLogger.debug("11129 L7guiFramework::getSnmpAgentData() in");
+ }
+ // --- debug log (in method) ---
+
+ SnmpAgentData snmpData = new SnmpAgentData();
+
+ L7vsAdmController admController = new L7vsAdmController();
+ L7vsAdmData admData = admController.getData();
+ L7vsConfController confController = new L7vsConfController();
+ try {
+ snmpData.status = admData.snmpStatus;
+
+ L7vsConfData confData = confController.getConfData();
+ snmpData.interval = confData.snmpInterval;
+ } catch (FileNotReadException e) {
+ ioFileLogger.error("41028 Exception occured: " + e.getMessage());
+ snmpData = null;
+ } catch (NullPointerException e) {
+ ioFileLogger.error("41029 Exception occured: " + e.getMessage());
+ snmpData = null;
+ } catch (Exception e) {
+ ioFileLogger.error("41030 Exception occured: " + e.getMessage());
+ snmpData = null;
+ }
+
+ // --- debug log (out method) ---
+ if (snmpLogger.isDebugEnabled()) {
+ snmpLogger.debug("11130 L7guiFramework::getSnmpAgentData() out return=(" + snmpData + ")");
+ }
+ // --- debug log (out method) ---
+ return snmpData;
+ }
+
+ /**
+ *
+ * <p>
+ * setSnmpAgentData method
+ * </p>
+ *
+ * @param s
+ * @return result of save l7vs.cf
+ */
+ public boolean setSnmpAgentData(SnmpAgentData s) {
+ // --- debug log (in method) ---
+ if (snmpLogger.isDebugEnabled()) {
+ snmpLogger.debug("11131 L7guiFramework::setSnmpAgentData(SnmpAgentData s) in s=(" + s + ")");
+ }
+ // --- debug log (in method) ---
+
+ boolean ret = true;
+ L7vsConfController confController = new L7vsConfController();
+ try {
+ L7vsConfData cf = confController.getConfData();
+ cf.snmpInterval = s.interval;
+ confController.setConfData(cf);
+ } catch (FileNotReadException e) {
+ ioFileLogger.error("41031 Exception occured: " + e.getMessage());
+ ret = false;
+ } catch (FileNotWriteException e) {
+ ioFileLogger.error("41032 Exception occured: " + e.getMessage());
+ ret = false;
+ } catch (NullPointerException e) {
+ ioFileLogger.error("41033 Exception occured: " + e.getMessage());
+ ret = false;
+ } catch (Exception e) {
+ ioFileLogger.error("41034 Exception occured: " + e.getMessage());
+ ret = false;
+ }
+
+ // --- debug log (out method) ---
+ if (snmpLogger.isDebugEnabled()) {
+ snmpLogger.debug("11132 L7guiFramework::setSnmpAgentData(SnmpAgentData s) out return=" + ret);
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * getL7vsConfData method
+ * </p>
+ *
+ * @return l7vs.cf data.
+ */
+ public L7vsConfData getL7vsConfData() {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11133 L7guiFramework::getL7vsConfData() in");
+ }
+ // --- debug log (in method) ---
+
+ L7vsConfController confController = new L7vsConfController();
+ L7vsConfData ret = null;
+ try {
+ ret = confController.getConfData();
+ } catch (FileNotReadException e) {
+ ioFileLogger.error("41035 Exception occured: " + e.getMessage());
+ ret = null;
+ } catch (Exception e) {
+ ioFileLogger.error("41036 Exception occured: " + e.getMessage());
+ ret = null;
+ }
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11134 L7guiFramework::getL7vsConfData() out return=" + ret);
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * setL7vsConfData method
+ * </p>
+ *
+ * @param cf
+ * @return result of save l7vs.cf
+ */
+ public boolean setL7vsConfData(L7vsConfData cf) {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11135 L7guiFramework::setL7vsConfData(L7vsConfData cf) in cf=(" + cf + ")");
+ }
+ // --- debug log (in method) ---
+
+ boolean ret = true;
+ L7vsConfController confController = new L7vsConfController();
+ try {
+ confController.setConfData(cf);
+ } catch (FileNotWriteException e) {
+ ioFileLogger.error("41037 Exception occured: " + e.getMessage());
+ ret = false;
+ } catch (Exception e) {
+ ioFileLogger.error("41038 Exception occured: " + e.getMessage());
+ ret = false;
+ }
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11136 L7guiFramework::setL7vsConfData(L7vsConfData cf) out return=" + ret);
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * getLogData method
+ * </p>
+ *
+ * @return log setting data.
+ */
+ public LogData getLogData() {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11137 L7guiFramework::getLogData() in");
+ }
+ // --- debug log (in method) ---
+
+ L7vsLogController logController = new L7vsLogController();
+ LogData ret = logController.getData();
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11138 L7guiFramework::getLogData() out return=(" + ret + ")");
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * saveExecute method
+ * </p>
+ *
+ * @param h
+ * @return
+ */
+ public boolean saveExecute(HashSet<SaveCategoryIdSet> h) {
+ // --- debug log (in method) ---
+ if (saveLogger.isDebugEnabled()) {
+ saveLogger.debug("11139 L7guiFramework::saveExecute(HashSet<SaveCategoryIdSet> h) in h=(" + h + ")");
+ }
+ // --- debug log (in method) ---
+
+ if (h == null) {
+ saveLogger.warn("31001 Invalid null argument.");
+ // --- debug log (out method) ---
+ if (saveLogger.isDebugEnabled()) {
+ saveLogger.debug("11140 L7guiFramework::saveExecute(HashSet<SaveCategoryIdSet> h) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ L7vsAdmController admController = new L7vsAdmController();
+ L7vsConfController confController = new L7vsConfController();
+ Iterator i = h.iterator();
+ while (i.hasNext()) {
+ SaveCategoryIdSet s = (SaveCategoryIdSet) i.next();
+ switch (s) {
+ case LOG_ID:
+ L7vsAdmData admData = admController.getData();
+ try {
+ L7vsConfData cf = confController.getConfData();
+ if (admData.l7vsdLogLevel.equals(cf.logger.lbLog.logLevel)
+ && admData.snmpLogLevel
+ .equals(cf.logger.snmpLog.logLevel)) {
+ saveLogger.info("21030 All log level settings have not changed.");
+ // --- debug log (out method) ---
+ if (saveLogger.isDebugEnabled()) {
+ saveLogger.debug("11141 L7guiFramework::saveExecute(HashSet<SaveCategoryIdSet> h) out return=false");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+ cf.logger.lbLog.logLevel = admData.l7vsdLogLevel;
+ cf.logger.snmpLog.logLevel = admData.snmpLogLevel;
+
+ confController.setConfData(cf);
+ } catch (FileNotReadException e) {
+ ioFileLogger.error("41039 Exception occured: " + e.getMessage());
+ // --- debug log (out method) ---
+ if (saveLogger.isDebugEnabled()) {
+ saveLogger.debug("11142 L7guiFramework::saveExecute(HashSet<SaveCategoryIdSet> h) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ } catch (FileNotWriteException e) {
+ ioFileLogger.error("41040 Exception occured: " + e.getMessage());
+ // --- debug log (out method) ---
+ if (saveLogger.isDebugEnabled()) {
+ saveLogger.debug("11143 L7guiFramework::saveExecute(HashSet<SaveCategoryIdSet> h) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ } catch (Exception e) {
+ ioFileLogger.error("41041 Exception occured: " + e.getMessage());
+ // --- debug log (out method) ---
+ if (saveLogger.isDebugEnabled()) {
+ saveLogger.debug("11144 L7guiFramework::saveExecute(HashSet<SaveCategoryIdSet> h) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+ break;
+ case VS_ID:
+ admData = admController.getData();
+ DirectorController directord = new DirectorController();
+ try {
+ DirectorData directorData = directord.getDirectorData();
+ boolean sameFlag = true;
+ int admVsCount = admData.virtualSettings.size();
+ Vector<VirtualSetting> delVsList = new Vector<VirtualSetting>();
+ for (VirtualSetting directorVs : directorData.virtualSettings) {
+ boolean found = false;
+ for (VirtualSetting admVs : admData.virtualSettings) {
+ if (admVs.isSameService(directorVs)) {
+ if (! admVs.equalsAdm(directorVs)) {
+ directorVs.sched = admVs.sched;
+ directorVs.qosclient = admVs.qosclient;
+ directorVs.qosservice = admVs.qosservice;
+ directorVs.maxconn = admVs.maxconn;
+ directorVs.sorryserver = admVs.sorryserver;
+ directorVs.real = admVs.real;
+ sameFlag = false;
+ }
+ admData.virtualSettings.remove(admVs);
+ found = true;
+ break;
+ }
+ }
+ if (found == false)
+ delVsList.add(directorVs);
+ }
+ for (VirtualSetting admVs : admData.virtualSettings) {
+ directorData.virtualSettings.add(admVs);
+ sameFlag = false;
+ }
+ for (VirtualSetting delVs : delVsList) {
+ directorData.virtualSettings.remove(delVs);
+ sameFlag = false;
+ }
+ if (sameFlag) {
+ saveLogger.info("21031 All Virtual Service setting have not changed.");
+ // --- debug log (out method) ---
+ if (saveLogger.isDebugEnabled()) {
+ saveLogger.debug("11145 L7guiFramework::saveExecute(HashSet<SaveCategoryIdSet> h) out return=false");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+ directord.setDirectorData(directorData);
+ } catch (FileNotReadException e) {
+ ioFileLogger.error("41042 Exception occured: " + e.getMessage());
+ // --- debug log (out method) ---
+ if (saveLogger.isDebugEnabled()) {
+ saveLogger.debug("11146 L7guiFramework::saveExecute(HashSet<SaveCategoryIdSet> h) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ } catch (FileNotWriteException e) {
+ ioFileLogger.error("41043 Exception occured: " + e.getMessage());
+ // --- debug log (out method) ---
+ if (saveLogger.isDebugEnabled()) {
+ saveLogger.debug("11147 L7guiFramework::saveExecute(HashSet<SaveCategoryIdSet> h) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ } catch (Exception e) {
+ ioFileLogger.error("41044 Exception occured: " + e.getMessage());
+ // --- debug log (out method) ---
+ if (saveLogger.isDebugEnabled()) {
+ saveLogger.debug("11148 L7guiFramework::saveExecute(HashSet<SaveCategoryIdSet> h) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+ break;
+ default:
+ saveLogger.warn("31002 Unknown save category was specified.");
+ // --- debug log (out method) ---
+ if (saveLogger.isDebugEnabled()) {
+ saveLogger.debug("11149 L7guiFramework::saveExecute(HashSet<SaveCategoryIdSet> h) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+ }
+
+ // --- debug log (out method) ---
+ if (saveLogger.isDebugEnabled()) {
+ saveLogger.debug("11150 L7guiFramework::saveExecute(HashSet<SaveCategoryIdSet> h) out return=true");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+
+ /**
+ *
+ * <p>
+ * syncExecute method
+ * </p>
+ *
+ * @param h
+ * @return result of sync file.
+ */
+ public boolean syncExecute(HashSet<Integer> h) {
+ // --- debug log (out method) ---
+ if (syncLogger.isDebugEnabled()) {
+ syncLogger.debug("11151 L7guiFramework::syncExecute(HashSet<Integer> h) in h=(" + h + ")");
+ }
+ // --- debug log (out method) ---
+
+ L7SyncManager sync = new L7SyncManager();
+ try {
+ sync.syncAct(h);
+ } catch (MessageView mv) {
+ syncLogger.error("41045 Exception occured: " + mv.getMessage());
+ // --- debug log (out method) ---
+ if (syncLogger.isDebugEnabled()) {
+ syncLogger.debug("11152 L7guiFramework::syncExecute(HashSet<Integer> h) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ // --- debug log (out method) ---
+ if (syncLogger.isDebugEnabled()) {
+ syncLogger.debug("11153 L7guiFramework::syncExecute(HashSet<Integer> h) out return=true");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+
+ /**
+ *
+ * <p>
+ * getL7vsdProcessStatus method
+ * </p>
+ *
+ * @return existence of l7vsd process.
+ */
+ public boolean getL7vsdProcessStatus() {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11154 L7guiFramework::getL7vsdProcessStatus() in");
+ }
+ // --- debug log (in method) ---
+
+ boolean ret = processCheck("l7vsd");
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11155 L7guiFramework::getL7vsdProcessStatus() out return=" + ret);
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * getL7directordProcessStatus method
+ * </p>
+ *
+ * @return existence of l7directord process.
+ */
+ public boolean getL7directordProcessStatus() {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11156 L7guiFramework::getL7directordProcessStatus() in");
+ }
+ // --- debug log (in method) ---
+
+ boolean ret = processCheck("l7directord");
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11157 L7guiFramework::getL7directordProcessStatus() out return=" + ret);
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * setLogLevel method
+ * </p>
+ *
+ * @param category
+ * @return result of l7vsadm set log level command.
+ */
+ public boolean setLogLevel(HashMap<LogData.LogCategory, LogData.LogLevel> category) {
+ // --- debug log (in method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11158 L7guiFramework::setLogLevel(HashMap<LogData.LogCategory, LogData.LogLevel> category in category=(" + category + ")");
+ }
+ // --- debug log (in method) ---
+
+ L7vsAdmController admController = new L7vsAdmController();
+ boolean ret = admController.setLogLevel(category);
+
+ // --- debug log (out method) ---
+ if (ioCommandLogger.isDebugEnabled()) {
+ ioCommandLogger.debug("11159 L7guiFramework::setLogLevel(HashMap<LogData.LogCategory, LogData.LogLevel> category out return=" + ret);
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * processCheck method
+ * </p>
+ *
+ * @param regex
+ * @return existence of regex process.
+ */
+ protected boolean processCheck(String regex) {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11160 L7guiFramework::processCheck(String regex) in regex=\"" + regex + "\"");
+ }
+ // --- debug log (in method) ---
+
+ boolean found = false;
+ String proc = "/proc";
+ Pattern p = Pattern.compile("^\\d+$");
+ Pattern l7vsd = Pattern.compile("^Name:\t" + regex + "$");
+
+ try {
+ File dir = new File(proc);
+ File[] procdir = dir.listFiles();
+ for (int i = 0; i < procdir.length; i++) {
+ Matcher m = p.matcher(procdir[i].getName());
+ if (m.matches()) {
+ BufferedReader f = null;
+ try {
+ f = new BufferedReader(new FileReader("/proc/"
+ + procdir[i].getName() + "/status"));
+ String line;
+ while ((line = f.readLine()) != null) {
+ Matcher mt = l7vsd.matcher(line);
+ if (mt.matches()) {
+ found = true;
+ break;
+ }
+ }
+ } catch (FileNotFoundException e) {
+ ioFileLogger.error("41046 Exception occured: " + e.getMessage());
+ } catch (IOException e) {
+ ioFileLogger.error("41047 Exception occured: " + e.getMessage());
+ } finally {
+ try {
+ if (f != null) {
+ f.close();
+ }
+ } catch (Exception e) {
+ ioFileLogger.error("41048 Exception occured: " + e.getMessage());
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ ioFileLogger.error("41049 Exception occured: " + e.getMessage());
+ }
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11161 L7guiFramework::processCheck(String regex) out return=" + found);
+ }
+ // --- debug log (out method) ---
+ return found;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+/**
+ * <p>
+ * class LogCategorySet
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author nakai
+ */
+public interface LogCategorySet {
+ public String L7VSD = "l7vsd";
+
+ public String L7VSADM = "l7vsadm";
+
+ public String L7DIRECTORD = "l7directord";
+
+ public String SNMPAGENT = "SNMPAgent";
+
+ public String L7GUI = "l7gui";
+
+ public String SYNC = "syncResource";
+
+ public String HA = "HA";
+
+ public String GUI_START_STOP = "l7gui_StartStop";
+
+ public String GUI_USER_AUTHENTICATION = "l7gui_UserAuthentication";
+
+ public String GUI_VIRTUALSERVICE = "l7gui_VirtualService";
+
+ public String GUI_MONITOR = "l7gui_Monitor";
+
+ public String GUI_SNMP = "l7gui_SnmpAgent";
+
+ public String GUI_REPLICATION = "l7gui_Replication";
+
+ public String GUI_LOG = "l7gui_Log";
+
+ public String GUI_USER_MANAGE = "l7gui_UserManage";
+
+ public String GUI_REDUNDANT = "l7gui_Redundant";
+
+ public String GUI_SAVE = "l7gui_Save";
+
+ public String GUI_SYNC = "l7gui_Sync";
+
+ public String GUI_SAVE_SYNC = "l7gui_SaveSync";
+
+ public String GUI_IO = "l7gui_I/O";
+
+ public String GUI_IO_FILE = "l7gui_I/O.File";
+
+ public String GUI_IO_COMMAND = "l7gui_I/O.Command";
+
+ public String SYNC_START_STOP = "l7sync_StartStop";
+
+ public String SYNC_CONNECTION = "l7sync_Connection";
+
+ public String SYNC_SYNC = "l7sync_Sync";
+
+ public String SYNC_SYNC_DIRECTOR_DATA = "l7sync_Sync.DirectorData";
+
+ public String SYNC_SYNC_L7VSDCONF_DATA = "l7sync_Sync.L7vsdConfData";
+
+ public String SYNC_SYNC_USER_DATA = "l7sync_Sync.UserData";
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+/**
+ * <p>class Message</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tsubone
+ */
+public interface Message {
+ public static final String INVALID_SESSSION = "Invalid session.";
+
+ public static final String UNEXPECTED_ERROR = "Unexpected error.";
+
+ public static final String USERID_PASSWORD_ERROR = "Invalid \"User ID\" or \"Password\".";
+
+ public static final String USER_AUTH_ERROR = "User Authentication failed.";
+
+ public static final String VALIDATION_ERROR = "Validation error.";
+
+ public static final String INVALID_VALUE = "Invalid value.";
+
+ public static final String REQUIED_ITEM = "Required fields.";
+
+ public static final String NOT_INPUT_ITEM = "Please fill in the required fields.";
+
+ public static final String DIRECTOR_DATA_ERROR = "Cannot get the l7directord.cf data.";
+
+ public static final String DIRECTOR_SYNTAX_ERROR = "Syntax error of l7directord.cf";
+
+ public static final String L7VS_CONF_DATA_ERROR = "Cannot get the l7vs.cf data.";
+
+ public static final String CLUSTER_DATA_ERROR = "Cannot get the cluster data.";
+
+ public static final String VS_SELECT_ERROR = "Please select one of the following VirtualServices.";
+
+ public static final String NOT_EQUAL = "The Password and confirmation Password do not match.";
+
+ public static final String PASSWORD_INVALID = "Invalid current Password.";
+
+ public static final String SAVE_CATEGORY_SELECT_ERROR = "Please select one or some of the followings.";
+
+ public static final String SAVE_LOG_VS_SUCCESS = "Log's and VirtualService's settings have been saved.";
+
+ public static final String SAVE_LOG_SUCCESS = "Log's setting has been saved.";
+
+ public static final String SAVE_VS_SUCCESS = "VirtualService's setting has been saved. ";
+
+ public static final String SAVE_LOG_FAIL = "Failed to save Log's setting.";
+
+ public static final String SAVE_VS_FAIL = "Failed to save VirtualService's setting.";
+
+ public static final String SAVE_LOG_VS_FAIL = "Failed to save Log's and VirtualService's settings";
+
+ public static final String NO_VS = "Such VirtualService does not exist.";
+
+ public static final String ADD_VS_ERROR = "Failed to add VirtualService.";
+
+ public static final String SYNC_CATEGORY_SELECT_ERROR = "Please select one or some of the followings.";
+
+ public static final String NOT_EXIST = "All fields are empty.";
+
+ public static final String WRITE_ERROR = "Cannot write file.";
+
+ public static final String WRITE_ERROR_L7DIRECTORD = "Cannot write new data to the l7directord.cf file.";
+
+ public static final String WRITE_ERROR_L7VS = "Cannot write new data to the l7vs.cf file.";
+
+ public static final String READ_ERROR = "Cannot read file.";
+
+ public static final String USER_CHANGE_SUCCESS = "User data changed.";
+
+ public static final String USER_ADD_SUCCESS = "New user added.";
+
+ public static final String USER_MAX = "GUI Users is up to 16 users. You cannot add over 16 users.";
+
+ public static final String SAME_USER_EXISTS = "Already the same user exists.";
+
+ public static final String USER_REMOVE_SELECT_ERROR = "Please select one or some of the followings.";
+
+ public static final String SELF_USER_DELETE = "Cannot delete yourself.";
+
+ public static final String USER_DELETE_SUCCESS = "User deleted.";
+
+ public static final String USER_DELETE_FAIL = "Failed to delete user.";
+
+ public static final String LOG_NOT_FOUND = "Log file is not found.";
+
+ public static final String REAL_SERVER_EXIST = "Already the same RealServer exists.";
+
+ public static final String VIRTUAL_SERVER_EXIST = "Already the same VirtualService exists.";
+
+ public static final String SYNC_ERROR_L7DIRECTORD = "Failed in the synchronization of the l7directord.cf file.";
+
+ public static final String SYNC_ERROR_L7VS = "Failed in the synchronization of the l7vs.cf file.";
+
+ public static final String L7VSADM_ERROR = "An error occurred while processing l7vsadm command.";
+
+ public static final String CLUSTER_COMMAND_ERROR = "An error occurred while processing cluster management command.";
+
+ public static final String DIRECTOR_SAVE = "Succeeded to modify monitor settings.";
+
+ public static final String DIRECTOR_SAVESYNC = "Succeeded to modify and sync monitor settings.";
+
+ public static final String VS_ADD_APPLY = "Succeeded to add a new VirtualService setting.";
+
+ public static final String VS_ADD_SAVE = "Succeeded to add and save a new VirtualService setting. If the settings is not reflected in the following list, please refresh this page after waited for a while.";
+
+ public static final String VS_ADD_SAVESYNC = "Succeeded to add, save, and sync a new VirtualService setting. If the settings is not reflected in the following list, please refresh this page after waited for a while.";
+
+ public static final String VS_REMOVE_APPLY = "Succeeded to remove a VirtualService setting.";
+
+ public static final String VS_REMOVE_SAVE = "Succeeded to remove and save a VirtualService setting. If the settings is not reflected in the following list, please refresh this page after waited for a while.";
+
+ public static final String VS_REMOVE_SAVESYNC = "Succeeded to remove and save, sync a VirtualService setting. If the settings is not reflected in the following list, please refresh this page after waited for a while.";
+
+ public static final String VS_MODIFY_APPLY = "Succeeded to modify VirtualService setting.";
+
+ public static final String VS_MODIFY_SAVE = "Succeeded to modify and save VirtualService setting. If the settings is not reflected in the following list, please refresh this page after waited for a while.";
+
+ public static final String VS_MODIFY_SAVESYNC = "Succeeded to modify, save and sync VirtualService setting. If the settings is not reflected in the following list, please refresh this page after waited for a while.";
+
+ public static final String CLUSTER_SWITCHORVER = "Succeeded to switch-over cluster.";
+
+ public static final String REP_MASTER = "Succeeded to start replication.";
+
+ public static final String REP_MASTER_STOP = "Succeeded to stop replication.";
+
+ public static final String REP_SLAVE = "Succeeded to start replication.";
+
+ public static final String REP_SLAVE_STOP = "Succeeded to stop replication.";
+
+ public static final String REP_INFO_SAVE = "Succeeded to modify and save replication setting.";
+
+ public static final String REP_INFO_SAVESYNC = "Succeeded to modify, save and sync replication setting.";
+
+ public static final String REP_START = "Succeeded to dump replication data.";
+
+ public static final String LOGLEVEL_CHANGE_APPLY = "Succeeded to change log level.";
+
+ public static final String LOGLEVEL_CHANGE_SAVE = "Succeeded to change and save log level.";
+
+ public static final String LOGLEVEL_CHANGE_SAVESYNC = "Succeeded to change, save and sync log level";
+
+ public static final String SNMP_INFO_SAVE = "Succeeded to change and save SNMP Agent setting.";
+
+ public static final String SNMP_INFO_SAVESYNC = "Succeeded to change, save and sync SNMP Agent setting.";
+
+ public static final String SYNC = "Succeeded to sync resources.";
+
+ // Messages for L7GUI synchronous processing
+ public static final String SYNC_INVALID_CATEGORY_ID = "Invalid category id.";
+
+ public static final String SYNC_ENCODE_ERROR = "Failed to serialize or encode.";
+
+ public static final String SYNC_DECODE_ERROR = "Failed to decode or deserialize.";
+
+ public static final String SYNC_SET_ERROR = "Failed to set ";
+
+ public static final String SYNC_GET_ERROR = "Failed to get data";
+
+ public static final String SYNC_OPEN_ERROR = "Failed to open connection";
+
+ public static final String SYNC_FAIL = "Failed to synchronize ";
+
+ public static final String SYNC_SEND_ERROR = "Failed to send data";
+
+ public static final String SYNC_INVALID_ARGUMENT = "Invalid argument supplied for";
+
+ public static final String SYNC_RECV_ERROR = "Failed to receive data";
+
+ public static final String SYNC_CLOSE_ERROR = "Failed to close connection.";
+
+ public static final String SYNC_INVALID_RECV_DATA = "Invalid receive data.";
+
+ public static final String SYNC_SUCCESS = " was synchronized.";
+
+ public static final String SYNC_DIFFERENT_DATA = "Different data between active server and stand-by server";
+
+ public static final String SYNC_SAME_DATA = "The same data between active server and stand-by server";
+
+ public static final String SYNC_INVALID_SERVER_MODE = "Invalid server mode.";
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+import java.io.Serializable;
+
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * <p>class MessageView</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tanuma
+ */
+public class MessageView extends Throwable implements Serializable {
+ static final long serialVersionUID = 1L;
+
+ private Logger ioLogger = Logger.getLogger(LogCategorySet.GUI_IO);
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_LOG);
+
+ protected String message = "";
+ protected int errno = 0;
+ protected String category = "";
+
+ /**
+ *
+ * Constructor
+ *
+ * @param errno
+ * @param category
+ * @param message
+ */
+ public MessageView(int errno, String category, String message) {
+ // --- debug log (constructor) ---
+ if (ioLogger.isDebugEnabled()) {
+ ioLogger.debug("11085 class MessageView created.");
+ }
+ // --- debug log (constructor) ---
+
+ if (message != null)
+ this.message = new String(message);
+ if (category != null)
+ this.category = new String(category);
+ this.errno = errno;
+
+ putLog();
+ }
+
+ /**
+ *
+ * Constructor
+ *
+ */
+ public MessageView() {
+ // --- debug log (constructor) ---
+ if (ioLogger.isDebugEnabled()) {
+ ioLogger.debug("11086 class MessageView created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /**
+ *
+ * <p> getMessage method</p>
+ *
+ * @return
+ */
+ public String getMessage() {
+ // --- debug log (in/out method) ---
+ if (ioLogger.isDebugEnabled()) {
+ ioLogger.debug("11087 MessageView::getMessage() in");
+ ioLogger.debug("11088 MessageView::getMessage() out return=\"" + this.message + "\"");
+ }
+ // --- debug log (in/out method) ---
+ return this.message;
+ }
+
+ /**
+ *
+ * <p> setMessage method</p>
+ *
+ * @param message
+ */
+ public void setMessage(String message) {
+ // --- debug log (in method) ---
+ if (ioLogger.isDebugEnabled()) {
+ ioLogger.debug("11089 MessageView::setMessage(String message) in message=\"" + message + "\"");
+ }
+ // --- debug log (in method) ---
+
+ this.message = message;
+ putLog();
+
+ // --- debug log (out method) ---
+ if (ioLogger.isDebugEnabled()) {
+ ioLogger.debug("11090 MessageView::setMessage(String message) out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ /**
+ *
+ * <p> getErrno method</p>
+ *
+ * @return
+ */
+ public int getErrno() {
+ // --- debug log (in/out method) ---
+ if (ioLogger.isDebugEnabled()) {
+ ioLogger.debug("11091 MessageView::getErrno() in");
+ ioLogger.debug("11092 MessageView::getErrno() out return=\"" + this.errno + "\"");
+ }
+ // --- debug log (in/out method) ---
+ return this.errno;
+ }
+
+ /**
+ *
+ * <p> setErrno method</p>
+ *
+ * @param errno
+ */
+ public void setErrno(int errno) {
+ // --- debug log (in method) ---
+ if (ioLogger.isDebugEnabled()) {
+ ioLogger.debug("11093 MessageView::setErrno(int errno) in errno=" + errno);
+ }
+ // --- debug log (in method) ---
+
+ this.errno = errno;
+
+ // --- debug log (out method) ---
+ if (ioLogger.isDebugEnabled()) {
+ ioLogger.debug("11094 MessageView::setErrno(int errno) out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ /**
+ *
+ * <p> getCategory method</p>
+ *
+ * @return
+ */
+ public String getCategory() {
+ // --- debug log (in/out method) ---
+ if (ioLogger.isDebugEnabled()) {
+ ioLogger.debug("11095 MessageView::getCategory() in");
+ ioLogger.debug("11096 MessageView::getCategory() out return=\"" + this.category + "\"");
+ }
+ // --- debug log (in/out method) ---
+ return this.category;
+ }
+
+ /**
+ *
+ * <p> setCategory method</p>
+ *
+ * @param category
+ */
+ public void setCategory(String category) {
+ // --- debug log (in method) ---
+ if (ioLogger.isDebugEnabled()) {
+ ioLogger.debug("11097 MessageView::setMessage(String category) in category=\"" + category + "\"");
+ }
+ // --- debug log (in method) ---
+
+ this.category = category;
+
+ // --- debug log (out method) ---
+ if (ioLogger.isDebugEnabled()) {
+ ioLogger.debug("11098 MessageView::setMessage(String category) out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ /**
+ *
+ * <p> putLog method</p>
+ *
+ */
+ protected void putLog() {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11099 MessageView::putLog() in");
+ }
+ // --- debug log (in method) ---
+
+ if (this.message != null && this.category != null && this.errno >= 10000) {
+ Logger logger = Logger.getLogger(this.category);
+ if (this.errno < 20000) {
+ logger.debug(this.errno + " " + this.message);
+ } else if (this.errno < 30000) {
+ logger.info(this.errno + " " + this.message);
+ } else if (this.errno < 40000) {
+ logger.warn(this.errno + " " + this.message);
+ } else if (this.errno < 50000) {
+ logger.error(this.errno + " " + this.message);
+ } else if (this.errno < 60000) {
+ logger.fatal(this.errno + " " + this.message);
+ }
+ }
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11100 MessageView::putLog() out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ public String toString() {
+ return
+ "message=\"" + this.message + "\", " +
+ "errno=" + this.errno + ", " +
+ "category=\"" + this.category + "\"";
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * <p>class Parameter</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tanuma
+ */
+public final class Parameter {
+
+ private Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE);
+ private static Logger ioFileLogger_s = Logger.getLogger(LogCategorySet.GUI_IO_FILE);
+
+ private static final String FILENAME = "/etc/l7vs/l7gui.cf";
+
+ /**
+ * parameter key name of session timeout
+ */
+ public static final String SESSION_TIMEOUT = "max_session_time";
+
+ /**
+ * parameter key name of session timeout
+ */
+ public static final String L7VSADM_TIMEOUT_FLAG = "l7vsadm_timeout_flag";
+
+ /**
+ * instance of this class (singleton)
+ */
+ protected static Parameter instance = null;
+
+ /**
+ * parameter map
+ */
+ protected HashMap<String, String> paramMap = null;
+
+ /**
+ *
+ * Constructor
+ *
+ */
+ protected Parameter() {
+ // --- debug log (constructor) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11001 class Parameter created.");
+ }
+ // --- debug log (constructor) ---
+ paramMap = new HashMap<String, String>();
+ try {
+ loadFromFile();
+ } catch(Exception e) {
+ ioFileLogger.error("41001 Cannot read l7gui.cf file.");
+ }
+ }
+
+ /**
+ *
+ * <p> getInstance method</p>
+ *
+ * @return instance of this class
+ */
+ public synchronized static Parameter getInstance() {
+ // --- debug log (in method) ---
+ if (ioFileLogger_s.isDebugEnabled()) {
+ ioFileLogger_s.debug("11002 Parameter::getInstance() in");
+ }
+ // --- debug log (in method) ---
+
+ if (instance == null) {
+ instance = new Parameter();
+ }
+
+ // --- debug log (out method) ---
+ if (ioFileLogger_s.isDebugEnabled()) {
+ ioFileLogger_s.debug("11003 Parameter::getInstance() out return=(" + instance + ")");
+ }
+ // --- debug log (out method) ---
+ return instance;
+ }
+
+ /**
+ *
+ * <p> loadFromFile method</p>
+ *
+ * @throws FileNotReadException
+ */
+ protected void loadFromFile() throws FileNotReadException {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11004 Parameter::loadFromFile() throws FileNotReadException in");
+ }
+ // --- debug log (in method) ---
+
+ BufferedReader br = null;
+ try {
+ br = new BufferedReader(new InputStreamReader(new FileInputStream(
+ FILENAME)));
+ String str = br.readLine();
+ while (str != null) {
+ str = str.replaceAll("\\s", "");
+ String[] params = str.split("=", 2);
+ if (params.length == 2) {
+ if (params[0].startsWith("#") == false)
+ this.setValue(params[0], params[1]);
+ }
+ str = br.readLine();
+ }
+ } catch (Exception e) {
+ StringBuffer buf = new StringBuffer();
+ FileNotReadException ex = new FileNotReadException();
+ buf.append("Cannot open file: ");
+ buf.append(FILENAME);
+ buf.append(" / Exception Message: ");
+ buf.append(e.getMessage());
+ ex.setFileName(FILENAME);
+ ex.setErrMessage(buf.toString());
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11005 Parameter::loadFromFile() throws FileNotReadException out exception=\"" + ex.toString() + "\"");
+ }
+ // --- debug log (out method) ---
+ throw ex;
+ }
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11006 Parameter::loadFromFile() throws FileNotReadException out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ /**
+ *
+ * <p> setValue method</p>
+ *
+ * @param key key with which the specified value is to be associated.
+ * @param value value to be associated with the specified key.
+ * @return previous value associated with specified key, or null if there was no mapping for key.
+ */
+ public String setValue(String key, String value) {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Parameter::setValue(String key, String value) in ");
+ buf.append("key=\"" + key + "\", ");
+ buf.append("value=\"" + value + "\"");
+ ioFileLogger.debug("11007 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ String oldValue = null;
+ if (key != null)
+ oldValue = paramMap.put(key, value);
+
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Parameter::setValue(String key, String value) out ");
+ buf.append("return=\"" + oldValue + "\"");
+ ioFileLogger.debug("11008 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+ return oldValue;
+ }
+
+ /**
+ *
+ * <p> getValue method</p>
+ *
+ * @param key the key whose associated value is to be returned.
+ * @return the value to which this map maps the specified key, or null if the map contains no mapping for this key.
+ */
+ public String getValue(String key) {
+ // --- debug log (in method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11009 Parameter::getValue(String key) in key=\"" + key + "\"");
+ }
+ // --- debug log (in method) ---
+
+ String value = paramMap.get(key);
+
+ // --- debug log (out method) ---
+ if (ioFileLogger.isDebugEnabled()) {
+ ioFileLogger.debug("11010 Parameter::getValue(String key) out return=\"" + value + "\"");
+ }
+ // --- debug log (out method) ---
+ return value;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public String toString() {
+ return "paramMap=(" + paramMap + ")";
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.util.Vector;
+
+import javax.mail.internet.MimeUtility;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.controller.DirectorData;
+import org.ultramonkey.l7.controller.L7vsConfData;
+
+/**
+ * <p>class Payload</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author momose
+ */
+public class Payload {
+ protected Logger debugLogger = Logger.getLogger(LogCategorySet.SYNC_SYNC);
+
+ protected Logger debugDirectorLogger = Logger
+ .getLogger(LogCategorySet.SYNC_SYNC_DIRECTOR_DATA);
+
+ protected Logger debugL7vsdConfLogger = Logger
+ .getLogger(LogCategorySet.SYNC_SYNC_L7VSDCONF_DATA);
+
+ protected Logger debugUserLogger = Logger
+ .getLogger(LogCategorySet.SYNC_SYNC_USER_DATA);
+
+ // �{�f�B����V���A���C�Y�����Abase64�G���R�[�h�����f�[�^�T�C�Y��i�[����int�ϐ�
+ protected int size;
+
+ // ����Ώۂ̃J�e�S��ID��i�[����int�ϐ�
+ protected int categoryId;
+
+ // ����Ώۃf�[�^��i�[����Object�ϐ�
+ protected Object body;
+
+ // �G���R�[�h��@��i�[����String�萔
+ protected final String ENCODING = "base64";
+
+ // �ʐM�f�[�^��size�̃L�[����i�[����String�萔
+ protected final String SIZE_KEY_STRING = "size=";
+
+ // �ʐM�f�[�^�̃J�e�S���̃L�[����i�[����String�萔
+ protected final String CATEGORY_KEY_STRING = "category=";
+
+ // �ʐM�f�[�^�̃{�f�B���̃L�[����i�[����String�萔
+ protected final String BODY_KEY_STRING = "body=";
+
+ // �ʐM�f�[�^�̉�s��i�[����String�萔
+ protected final String separator = "\r\n";
+
+ // �T�C�Y�̒l�̌�����i�[����萔
+ protected final int SIZE_PADDING_NUMBER = 7;
+
+ // �J�e�S���̒l�̌�����i�[����萔
+ protected final int CATEGORY_PADDING_NUMBER = 2;
+
+ // payload�N���X�̍��ڐ��i�T�C�Y�A�J�e�S��ID�A�{�f�B�j
+ protected final int ENTRY_NUMBER = 3;
+
+ /**
+ * Constructor
+ *
+ * @param str recieve data
+ * @throws MessageView
+ */
+ public Payload(String[] str) throws MessageView {
+ // debug log(constructor)
+ if (debugLogger.isDebugEnabled()) {
+ debugLogger.debug("11175 class Payload created.");
+ }
+
+ // �T�C�Y�̃L�[�ƒl��i�[����String�ϐ�
+ String sizeStr = str[0];
+ // �L�[�ƒl��"="�ŕ���
+ String[] sizeSplit = sizeStr.split("=");
+ // �擾�����T�C�Y�̒l��size�Ɋi�[
+ size = Integer.parseInt(sizeSplit[1]);
+
+ // �J�e�S��ID�̃L�[�ƒl��i�[����String�ϐ�
+ String categoryStr = str[1];
+ // �L�[�ƒl��"="�ŕ���
+ String[] categorySplit = categoryStr.split("=");
+ // �擾�����J�e�S��ID�̒l��cateogyId�Ɋi�[
+ categoryId = Integer.parseInt(categorySplit[1]);
+
+ // �{�f�B�̃L�[�ƒl��i�[����String�ϐ�
+ String bodyStr = str[2];
+ // �L�[�ƒl��"="�ŕ���
+ String[] bodySplit = bodyStr.split("=", 2);
+ // �擾�����{�f�B�̃T�C�Y���r����
+
+ if (bodySplit[1].length() != size) {
+ // �f�[�^�̎擾���s�̃��b�Z�[�W��ԋp
+ throw new MessageView(40003, LogCategorySet.SYNC_SYNC, Message.SYNC_GET_ERROR
+ + " : payload");
+ }
+
+ // �J�e�S��ID��SYNC_OK��SYNC_NG�ȊO�̏ꍇ
+ if ((SyncCategoryIdSet.SYNC_OK != categoryId)
+ && (SyncCategoryIdSet.SYNC_NG != categoryId)) {
+ // �擾�����{�f�B�̒l��body�Ɋi�[
+ body = decodeAndDeserialize(bodySplit[1]);
+ }
+ }
+
+ /**
+ * Constructor
+ *
+ * @param categoryId
+ * @param userData
+ * @throws MessageView
+ */
+ public Payload(int categoryId, Vector<UserData> userData) throws MessageView {
+ // debug log(constructor)
+ if (debugUserLogger.isDebugEnabled()) {
+ debugUserLogger.debug("11176 class Payload created.");
+ }
+ // �J�e�S��ID��USER_DATA_ID�̏ꍇ
+ switch (categoryId) {
+ case SyncCategoryIdSet.USERDATA_ID:
+ // �T�C�Y�͐ݒ肵�Ȃ�
+ size = 0;
+ // ��̃J�e�S��ID��categoryId�ɐݒ�
+ this.categoryId = categoryId;
+ // ���UserData��Object�^�Ƃ���body�ɐݒ�
+ setBody((Object) userData);
+ break;
+
+ // �f�[�^�N���X�ɑ��݂��Ȃ��J�e�S����w�肵���ꍇ
+ default:
+ // �J�e�S�������s���ł��郁�b�Z�[�W��ԋp
+ throw new MessageView(40004, LogCategorySet.SYNC_SYNC_USER_DATA,
+ Message.SYNC_INVALID_CATEGORY_ID);
+ }
+ }
+
+ /**
+ * Constructor
+ *
+ * @param categoryId
+ * @param directorData
+ * @throws MessageView
+ */
+ public Payload(int categoryId, DirectorData directorData) throws MessageView {
+ // debug log(constructor)
+ if (debugDirectorLogger.isDebugEnabled()) {
+ debugDirectorLogger.debug("11177 class Payload created.");
+ }
+ switch (categoryId) {
+ // �J�e�S��ID��MONITOR_ID��SERVICE_ID�̏ꍇ
+ case SyncCategoryIdSet.MONITOR_ID:
+ case SyncCategoryIdSet.SERVICE_ID:
+ case SyncCategoryIdSet.SYNC_OK:
+ case SyncCategoryIdSet.SYNC_NG:
+ // �T�C�Y�͐ݒ肵�Ȃ�
+ size = 0;
+ // ��̃J�e�S��ID��categoryId�ɐݒ�
+ this.categoryId = categoryId;
+ // ���DirectorData��Object�^�Ƃ���body�ɐݒ�
+ setBody((Object) directorData);
+ break;
+
+ // �f�[�^�N���X�ɑ��݂��Ȃ��J�e�S����w�肵���ꍇ
+ default:
+ // �J�e�S�������s���ł��郁�b�Z�[�W��ԋp
+ throw new MessageView(40005, LogCategorySet.SYNC_SYNC_DIRECTOR_DATA,
+ Message.SYNC_INVALID_CATEGORY_ID);
+ }
+ }
+
+ /**
+ * Constructor
+ *
+ * @param categoryId
+ * @param l7vsConfData
+ * @throws MessageView
+ */
+ public Payload(int categoryId, L7vsConfData l7vsConfData) throws MessageView {
+ // debug log(constructor)
+ if (debugL7vsdConfLogger.isDebugEnabled()) {
+ debugL7vsdConfLogger.debug("11178 class Payload created.");
+ }
+ // �J�e�S��ID��L7VSD_LOG_ID�AADM_LOG_ID�ASNMP_LOG_ID�AREPLICATION_INFO_ID�AADM_INFO_ID�̏ꍇ
+ switch (categoryId) {
+ case SyncCategoryIdSet.L7VSD_LOG_ID:
+ case SyncCategoryIdSet.ADM_LOG_ID:
+ case SyncCategoryIdSet.SNMP_LOG_ID:
+ case SyncCategoryIdSet.REPLICATION_INFO_ID:
+ case SyncCategoryIdSet.SNMP_INFO_ID:
+ case SyncCategoryIdSet.ADM_INFO_ID:
+ case SyncCategoryIdSet.LOG_ALL_ID:
+ // �T�C�Y�͐ݒ肵�Ȃ�
+ size = 0;
+ // ��̃J�e�S��ID��categoryId�ɐݒ�
+ this.categoryId = categoryId;
+ // ���L7vsConfData��Object�^�Ƃ���body�ɐݒ�
+ setBody((Object) l7vsConfData);
+ break;
+
+ // �f�[�^�N���X�ɑ��݂��Ȃ��J�e�S����w�肵���ꍇ
+ default:
+ // �J�e�S�������s���ł��郁�b�Z�[�W��ԋp
+ throw new MessageView(40006, LogCategorySet.SYNC_SYNC_L7VSDCONF_DATA,
+ Message.SYNC_INVALID_CATEGORY_ID);
+ }
+ }
+
+ /**
+ * <p> Gets body.</p>
+ *
+ * @return body�@
+ */
+ protected Object getBody() {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Payload::getBody() in ");
+ debugLogger.debug("11179 " + buf.toString());
+ }
+
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Payload::getBody() out ");
+ buf.append("return= " + body.toString());
+ debugLogger.debug("11180 " + buf.toString());
+ }
+
+ //�@�{�f�B����ԋp
+ return body;
+ }
+
+ /**
+ * <p> Sets body.</p>
+ *
+ * @param body
+ */
+ protected void setBody(Object body) {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Payload::setBody(Object body) in ");
+ buf.append("body= " + body.toString());
+ debugLogger.debug("11181 " + buf.toString());
+ }
+
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Payload::setBody(Object body) out ");
+ debugLogger.debug("11182 " + buf.toString());
+ }
+ // body����ݒ�
+ this.body = body;
+ }
+
+ /**
+ * <p> Serializes and encodes data.</p>
+ *
+ * @return formatted data
+ * @throws MessageView
+ */
+ protected String serializeAndEncode() throws MessageView {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Payload::serializeAndEncode() throws MessageView in ");
+ debugLogger.debug("11183 " + buf.toString());
+ }
+
+ try {
+ // �擾�����f�[�^��V���A���C�Y
+ ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
+ ObjectOutputStream outputStream = new ObjectOutputStream(byteArray);
+ outputStream.writeObject(body);
+ outputStream.flush();
+ outputStream.close();
+
+ // �V���A���C�Y�����f�[�^��Base64�ŃG���R�[�h
+ OutputStream base64OutputStream = MimeUtility.encode(byteArray, ENCODING);
+ byte[] serializeByte = byteArray.toByteArray();
+ byteArray.reset();
+ base64OutputStream.write(serializeByte);
+ base64OutputStream.close();
+
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Payload::serializeAndEncode() throws MessageView out ");
+ buf.append("return= " + byteArray.toString());
+ debugLogger.debug("11184 " + buf.toString().replaceAll("[\r\n]", ""));
+ }
+ // �G���R�[�h�����f�[�^��ԋp
+ return byteArray.toString().replaceAll("[\r\n]", "");
+
+ // �V���A���C�Y�܂��̓G���R�[�h�Ɏ��s�����ꍇ
+ } catch (Exception e) {
+ // �V���A���C�Y���s�̃��b�Z�[�W��ԋp
+ throw new MessageView(40007, LogCategorySet.SYNC_SYNC,
+ Message.SYNC_ENCODE_ERROR);
+ }
+
+ }
+
+ /**
+ * <p> Decodes and deserializes data.</p>
+ *
+ * @param body body data which is serialized and encoded
+ * @return data at body
+ * @throws MessageView
+ */
+ protected Object decodeAndDeserialize(String body) throws MessageView {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("Payload::decodeAndDeserialize(String body) throws MessageView in ");
+ buf.append("body= " + body);
+ debugLogger.debug("11185 " + buf.toString());
+ }
+
+ try {
+ // �f�R�[�h�����f�[�^��i�[����byte�z��
+ byte[] readBytes = new byte[10000000];
+
+ // body��Base64�Ńf�R�[�h
+ InputStream base64InputStream = MimeUtility.decode(new ByteArrayInputStream(
+ body.getBytes()), "base64");
+ // �f�R�[�h�����f�[�^��擾
+ base64InputStream.read(readBytes);
+
+ // �f�R�[�h�����f�[�^��f�V���A���C�Y���邽�߂�ObjectInputStream�C���X�^���X
+ ObjectInputStream inputStream = new ObjectInputStream(
+ new ByteArrayInputStream(readBytes));
+
+ Object result = inputStream.readObject();
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("Payload::decodeAndDeserialize(String body) throws MessageView out ");
+ buf.append("return= " + result.toString());
+ debugLogger.debug("11186 " + buf.toString());
+ }
+
+ // �f�V���A���C�Y�������ʂ�ԋp
+ return result;
+
+ // �f�V���A���C�Y�܂��̓f�R�[�h�Ɏ��s�����ꍇ
+ } catch (Exception e) {
+ // �f�V���A���C�Y���s�̃��b�Z�[�W��ԋp
+ throw new MessageView(40008, LogCategorySet.SYNC_SYNC,
+ Message.SYNC_DECODE_ERROR + e);
+ }
+ }
+
+ /**
+ * <p> Formats data.</p>
+ *
+ * @return formatted data
+ * @throws MessageView
+ */
+ public String[] getMessage() throws MessageView {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Payload::getMessage() throws MessageView in ");
+ debugLogger.debug("11187 " + buf.toString());
+ }
+
+ // Base64�G���R�[�h���A�V���A���C�Y�����{�f�B����i�[����String�ϐ�
+ String body = serializeAndEncode();
+ // �G���R�[�h�ƃV���A���C�Y��̃{�f�B���̒�����i�[����String�ϐ�
+ String sizeNumber = new Integer(body.length()).toString();
+ // �J�e�S��ID��i�[����String�ϐ�
+ String categoryStr = new Integer(categoryId).toString();
+
+ // ���`��̃T�C�Y��i�[����StringBuffer�C���X�^���X
+ StringBuffer sizeBuffer = new StringBuffer();
+ //�@�T�C�Y�̃L�[����lj�
+ sizeBuffer.append(SIZE_KEY_STRING);
+ // �T�C�Y��0�p�f�B���O���A�l��lj�
+ sizeBuffer.append(sizeNumber);
+ for (int count = 0; count < SIZE_PADDING_NUMBER - sizeNumber.length(); count++) {
+ sizeBuffer.insert(SIZE_KEY_STRING.length(), "0");
+ }
+
+ // ���`��̃J�e�S����i�[����StringBuffer�C���X�^���X
+ StringBuffer categoryBuffer = new StringBuffer();
+ // �J�e�S���̃L�[����lj�
+ categoryBuffer.append(CATEGORY_KEY_STRING);
+ // �J�e�S����0�p�f�B���O���A�l��lj�
+ categoryBuffer.append(categoryStr);
+ for (int count = 0; count < CATEGORY_PADDING_NUMBER - categoryStr.length(); count++) {
+ categoryBuffer.insert(CATEGORY_KEY_STRING.length(), "0");
+ }
+
+ // ���`��̃{�f�B��i�[����StringBuffer�C���X�^���X
+ StringBuffer bodyBuffer = new StringBuffer();
+ // �{�f�B�̃L�[����lj�
+ bodyBuffer.append(BODY_KEY_STRING);
+ // �{�f�B�̒l��lj�
+ bodyBuffer.append(body);
+
+ // Payload�N���X�𐮌`�����f�[�^�i�[����String�^�z��
+ String[] messageArray = new String[ENTRY_NUMBER];
+ // �T�C�Y��messageArray�Ɋi�[
+ messageArray[0] = sizeBuffer.toString();
+ // �J�e�S����messageArray�Ɋi�[
+ messageArray[1] = categoryBuffer.toString();
+ // �{�f�B��messageArray�Ɋi�[
+ messageArray[2] = bodyBuffer.toString();
+
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Payload::getMessage() throws MessageView out ");
+ buf.append("return= " + messageArray.toString());
+ debugLogger.debug("11188 " + buf.toString());
+ }
+
+ // ���`��̏���ԋp
+ return messageArray;
+ }
+
+ /**
+ * <p> Gets UserData from Payload.</p>
+ *
+ * @return userData
+ */
+ public Vector<UserData> getUserData() {
+ // debug log(in method)
+ if (debugUserLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Payload::getUserData() in ");
+ debugUserLogger.debug("11189 " + buf.toString());
+ }
+ // debug log(out method)
+ if (debugUserLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Payload::getUserData() out ");
+ buf.append("return= " + ((Vector<UserData>) body).toString());
+ debugUserLogger.debug("11190 " + buf.toString());
+ }
+
+ // �{�f�B����UserData�^�ɕϊ����ĕԋp
+ return (Vector<UserData>) body;
+ }
+
+ /**
+ * <p> Gets DirectorData from Payload.</p>
+ *
+ * @return directorData
+ */
+ public DirectorData getDirectorData() {
+ // debug log(in method)
+ if (debugDirectorLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Payload::getDirectorData() in ");
+ debugLogger.debug("11191 " + buf.toString());
+ }
+ // debug log(out method)
+ if (debugDirectorLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Payload::getDirectorData() out ");
+ buf.append("return= " + ((DirectorData) body).toString());
+ debugDirectorLogger.debug("11192 " + buf.toString());
+ }
+ // �{�f�B����DirectorData�^�ɕϊ����ĕԋp
+ return (DirectorData) body;
+ }
+
+ /**
+ * <p> Gets L7vsdConfData from Payload.</p>
+ *
+ * @return l7vsdConfData
+ */
+ public L7vsConfData getL7vsdConfData() {
+ // debug log(in method)
+ if (debugL7vsdConfLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Payload::getL7vsdConfData() in ");
+ debugL7vsdConfLogger.debug("11193 " + buf.toString());
+ }
+ // debug log(out method)
+ if (debugL7vsdConfLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Payload::getL7vsdConfData() out ");
+ buf.append("return= " + ((L7vsConfData) body).toString());
+ debugL7vsdConfLogger.debug("11194 " + buf.toString());
+ }
+ // �{�f�B����l7vsConfData�^�ɕϊ����ĕԋp
+ return (L7vsConfData) body;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+/**
+ * <p>class SyncCategoryId</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tanuma
+ */
+public enum SaveCategoryIdSet {
+
+ /**
+ * save category: virtual service setting
+ */
+ VS_ID,
+
+ /**
+ * save category: log level setting
+ */
+ LOG_ID
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+import java.io.Serializable;
+
+import org.apache.log4j.Logger;
+
+public class SessionTransData implements Serializable {
+ static final long serialVersionUID = 1;
+
+ private Logger syncLogger = Logger.getLogger(LogCategorySet.GUI_SYNC);
+
+ public String sourceURI;
+ public String destURI;
+ public String errorURI;
+ public int mode;
+
+ public SessionTransData() {
+ // --- debug log (constructor) ---
+ if (syncLogger.isDebugEnabled()) {
+ syncLogger.debug("11230 class SessionTransData created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ public SessionTransData(String sourceURI, String destURI, String errorURI, int mode) {
+ // --- debug log (constructor) ---
+ if (syncLogger.isDebugEnabled()) {
+ syncLogger.debug("11231 class SessionTransData created.");
+ }
+ // --- debug log (constructor) ---
+ this.sourceURI = sourceURI;
+ this.destURI = destURI;
+ this.errorURI = errorURI;
+ this.mode = mode;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+//import java.util.logging.Logger;
+import org.apache.log4j.Logger;
+
+/**
+ * <p>class SyncCategoryId</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author momose
+ */
+public class SyncCategoryIdSet {
+ protected static Logger debugLogger = Logger.getLogger(LogCategorySet.SYNC_SYNC);
+
+ static public final int SYNC_OK = 1;
+
+ static public final int SYNC_NG = 2;
+
+ static public final int L7VSD_LOG_ID = 3;
+
+ static public final int ADM_LOG_ID = 4;
+
+ static public final int SNMP_LOG_ID = 5;
+
+ static public final int REPLICATION_INFO_ID = 6;
+
+ static public final int SNMP_INFO_ID = 7;
+
+ static public final int ADM_INFO_ID = 8;
+
+ static public final int MONITOR_ID = 9;
+
+ static public final int SERVICE_ID = 10;
+
+ static public final int USERDATA_ID = 11;
+
+ static public final int LOG_ALL_ID = 12;
+
+ /**
+ * <p> change category name to category ID</p>
+ *
+ * @param inStr category name
+ * @return
+ * @throws MessageView
+ */
+ public static int toCategoryId(String inStr) throws MessageView {
+
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView in ");
+ buf.append("inStr= " + inStr);
+ debugLogger.debug("11195 " + buf.toString());
+ }
+
+ if (inStr.equals("SYNC_OK")) {
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
+ buf.append("return= SYNC_OK");
+ debugLogger.debug("11196 " + buf.toString());
+ }
+ return SYNC_OK;
+ }
+ if (inStr.equals("SYNC_NG")) {
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
+ buf.append("return= SYNC_NG");
+ debugLogger.debug("11197 " + buf.toString());
+ }
+ return SYNC_NG;
+ }
+ if (inStr.equals("l7vsd_log")) {
+ // debug log (out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
+ buf.append("return= L7VSD_LOG_ID");
+ debugLogger.debug("11198 " + buf.toString());
+ }
+ return L7VSD_LOG_ID;
+ }
+ if (inStr.equals("adm_log")) {
+ // debug log (out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
+ buf.append("return= ADM_LOG_ID");
+ debugLogger.debug("11199 " + buf.toString());
+ }
+ return ADM_LOG_ID;
+ }
+ if (inStr.equals("snmp_log")) {
+ // debug log (out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
+ buf.append("return= SNMP_LOG_ID");
+ debugLogger.debug("11200 " + buf.toString());
+ }
+ return SNMP_LOG_ID;
+ }
+ if (inStr.equals("replication_info")) {
+ // debug log (out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
+ buf.append("return= REPLICATION_INFO_ID");
+ debugLogger.debug("11201 " + buf.toString());
+ }
+ return REPLICATION_INFO_ID;
+ }
+ if (inStr.equals("snmp_info")) {
+ // debug log (out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
+ buf.append("return= SNMP_INFO_ID");
+ debugLogger.debug("11202 " + buf.toString());
+ }
+ return SNMP_INFO_ID;
+ }
+ if (inStr.equals("adm_info")) {
+ // debug log (out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
+ buf.append("return= ADM_INFO_ID");
+ debugLogger.debug("11203 " + buf.toString());
+ }
+ return ADM_INFO_ID;
+ }
+ if (inStr.equals("monitor")) {
+ // debug log (out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
+ buf.append("return= MONITOR_ID");
+ debugLogger.debug("11204 " + buf.toString());
+ }
+ return MONITOR_ID;
+ }
+ if (inStr.equals("service")) {
+ // debug log (out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
+ buf.append("return= SERVICE_ID");
+ debugLogger.debug("11205 " + buf.toString());
+ }
+ return SERVICE_ID;
+ }
+ if (inStr.equals("userdata")) {
+ // debug log (out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
+ buf.append("return= USERDATA_ID");
+ debugLogger.debug("11206 " + buf.toString());
+ }
+ return USERDATA_ID;
+ }
+ if (inStr.equals("log_all")) {
+ // debug log (out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
+ buf.append("return= LOG_ALL_ID");
+ debugLogger.debug("11207 " + buf.toString());
+ }
+ return LOG_ALL_ID;
+ } else
+ throw new MessageView(40001, LogCategorySet.SYNC_SYNC,
+ Message.SYNC_INVALID_ARGUMENT + " toCategoryId : " + inStr);
+
+ }
+
+ /**
+ * <p> change category ID to category name</p>
+ *
+ * @param categoryId category ID
+ * @return category name
+ * @throws MessageView
+ */
+ public static String toCategoryName(int categoryId) throws MessageView {
+ // debug log(in method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView in ");
+ buf.append("categoryId= " + categoryId);
+ debugLogger.debug("11208 " + buf.toString());
+ }
+
+ switch (categoryId) {
+ case L7VSD_LOG_ID:
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
+ buf.append("return= l7vsd_log");
+ debugLogger.debug("11209 " + buf.toString());
+ }
+ return "l7vsd_log";
+
+ case ADM_LOG_ID:
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
+ buf.append("return= adm_log");
+ debugLogger.debug("11210 " + buf.toString());
+ }
+ return "adm_log";
+
+ case SNMP_LOG_ID:
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
+ buf.append("return= snmp_log");
+ debugLogger.debug("11211 " + buf.toString());
+ }
+
+ return "snmp_log";
+
+ case REPLICATION_INFO_ID:
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
+ buf.append("return= replication_info");
+ debugLogger.debug("11212 " + buf.toString());
+ }
+ return "replication_info";
+
+ case SNMP_INFO_ID:
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
+ buf.append("return= snmp_info");
+ debugLogger.debug("11213 " + buf.toString());
+ }
+ return "snmp_info";
+
+ case ADM_INFO_ID:
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
+ buf.append("return= adm_info");
+ debugLogger.debug("11214 " + buf.toString());
+ }
+ return "adm_info";
+
+ case MONITOR_ID:
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
+ buf.append("return= monitor");
+ debugLogger.debug("11215 " + buf.toString());
+ }
+ return "monitor";
+
+ case SERVICE_ID:
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
+ buf.append("return= service");
+ debugLogger.debug("11216 " + buf.toString());
+ }
+ return "service";
+
+ case USERDATA_ID:
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
+ buf.append("return= userdata");
+ debugLogger.debug("11217 " + buf.toString());
+ }
+ return "userdata";
+
+ case LOG_ALL_ID:
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
+ buf.append("return= log_all");
+ debugLogger.debug("11218 " + buf.toString());
+ }
+ return "log_all";
+
+ case SYNC_OK:
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
+ buf.append("return= sync_ok");
+ debugLogger.debug("11219 " + buf.toString());
+ }
+ return "sync_ok";
+
+ case SYNC_NG:
+ // debug log(out method)
+ if (debugLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
+ buf.append("return= sync_ng");
+ debugLogger.debug("11220 " + buf.toString());
+ }
+ return "sync_ng";
+
+ default:
+ throw new MessageView(40002, LogCategorySet.SYNC_SYNC,
+ Message.SYNC_INVALID_ARGUMENT + " toCategoryName : "
+ + categoryId);
+ }
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+import java.io.Serializable;
+
+import org.apache.log4j.Logger;
+
+/**
+ * <p>class UserData</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author nakai
+ */
+public class UserData implements Serializable {
+ static final long serialVersionUID = 1L;
+
+ public String userName = null;
+ public String passwd = null;
+ public int acl = -1;
+ public String description = null;
+
+ /**
+ *
+ * Constructor
+ *
+ */
+ public UserData() {
+ // --- debug log (constructor) ---
+ Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE);
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11080 class UserData created.");
+ }
+ // --- debug log (constructor) ---
+ this.userName = null;
+ this.passwd = null;
+ this.acl = -1;
+ this.description = null;
+ }
+
+ public UserData(UserData copy) {
+ // --- debug log (constructor) ---
+ Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE);
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11081 class UserData created.");
+ }
+ // --- debug log (constructor) ---
+ if (copy.userName != null)
+ this.userName = copy.userName;
+ if (copy.passwd != null)
+ this.passwd = copy.passwd;
+ if (copy.description != null)
+ this.description = copy.description;
+ this.acl = copy.acl;
+ }
+
+ /**
+ *
+ * <p> equals method</p>
+ *
+ * @param user
+ * @return
+ */
+ public boolean equals(UserData user) {
+ // --- debug log (in method) ---
+ Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE);
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11082 Parameter::equals(UserData user) in user=(" + user + ")");
+ }
+ // --- debug log (in method) ---
+
+ if (user != null &&
+ this.userName.equals(user.userName) &&
+ this.passwd.equals(user.passwd) &&
+ this.acl == user.acl) {
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11083 Parameter::equals(UserData user) return=true");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11084 Parameter::equals(UserData user) return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ public String toString() {
+ return
+ "userName=\"" + this.userName + "\", " +
+ "passwd=\"" + this.passwd + "\", " +
+ "acl=" + this.acl + ", " +
+ "description=\"" + this.description + "\"";
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.model;
+
+import java.util.Vector;
+import java.io.*;
+import javax.servlet.http.*;
+
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * <p>
+ * class UserManager
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author tanuma
+ */
+public final class UserManager {
+ static final long serialVersionUID = 1;
+
+ /**
+ * userdata save filename ("/opt/l7vsd/userdata.dat")
+ */
+ protected static final String FileName = "/opt/l7vsd/userdata.dat";
+
+ /**
+ * instance of this class (singleton)
+ */
+ protected static UserManager instance = null;
+
+ /**
+ * userdata structure
+ */
+ protected Vector<UserData> uservec = null;
+ protected Vector<UserData> olduservec = null;
+
+ protected UserManager() throws FileNotReadException {
+ // --- debug log (constructor) ---
+ Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE);
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11011 class UserManager created.");
+ }
+ // --- debug log (constructor) ---
+
+ uservec = new Vector<UserData>();
+ this.loadFromFile();
+ }
+
+ /**
+ *
+ * <p>
+ * getInstance method
+ * </p>
+ *
+ * @return instance of this class.
+ */
+ public synchronized static UserManager getInstance() {
+ // --- debug log (in method) ---
+ Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE);
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11012 UserManager::getInstance() in");
+ }
+ // --- debug log (in method) ---
+
+ if (instance == null) {
+ try {
+ instance = new UserManager();
+ } catch (FileNotReadException e) {
+ userLogger.error("41002 Exception occured: " + e.getMessage());
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11013 UserManager::getInstance() out return=null");
+ }
+ // --- debug log (out method) ---
+ return null;
+ }
+ }
+
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11014 UserManager::getInstance() out return=(" + instance + ")");
+ }
+ // --- debug log (out method) ---
+ return instance;
+ }
+
+ /**
+ * save function
+ *
+ * @return true/false
+ */
+ protected void saveToFile() throws FileNotWriteException {
+ // --- debug log (in method) ---
+ Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE);
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11015 UserManager::saveToFile() throws FileNotWriteException in");
+ }
+ // --- debug log (in method) ---
+
+ try {
+ ObjectOutputStream oos = new ObjectOutputStream(
+ new FileOutputStream(FileName));
+ oos.writeObject(uservec);
+ oos.close();
+ } catch (IOException e) {
+ this.uservec = this.olduservec;
+ FileNotWriteException exception = new FileNotWriteException();
+ exception.setFileName(FileName);
+ exception.setErrMessage("Cannot write file.");
+ userLogger.error("41003 Exception occured: " + e.getMessage());
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11016 UserManager::saveToFile() throws FileNotWriteException out exception=\"" + exception.toString() + "\"");
+ }
+ // --- debug log (out method) ---
+ throw exception;
+ }
+
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11017 UserManager::saveToFile() throws FileNotWriteException out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ /**
+ * load function
+ *
+ * @return true/false
+ */
+ protected void loadFromFile() throws FileNotReadException {
+ // --- debug log (in method) ---
+ Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE);
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11018 UserManager::loadFromFile() throws FileNotReadException in");
+ }
+ // --- debug log (in method) ---
+
+ try {
+ ObjectInputStream ois = new ObjectInputStream(
+ new FileInputStream(FileName));
+ uservec = (Vector<UserData>) ois.readObject();
+ ois.close();
+ } catch (FileNotFoundException ex) {
+ FileNotReadException exception = new FileNotReadException();
+ exception.setFileName(FileName);
+ exception.setErrMessage("Cannot read file.");
+ userLogger.error("41004 Exception occured: " + ex.getMessage());
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11019 UserManager::loadFromFile() throws FileNotReadException out exception=\"" + exception.toString() + "\"");
+ }
+ // --- debug log (out method) ---
+ throw exception;
+ } catch (IOException ex) {
+ FileNotReadException exception = new FileNotReadException();
+ exception.setFileName(FileName);
+ exception.setErrMessage("Catch IOException: " + ex.getMessage());
+ userLogger.error("41005 Exception occured: " + ex.getMessage());
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11020 UserManager::loadFromFile() throws FileNotReadException out exception=\"" + exception.toString() + "\"");
+ }
+ // --- debug log (out method) ---
+ throw exception;
+ } catch (ClassNotFoundException ex) {
+ FileNotReadException exception = new FileNotReadException();
+ exception.setFileName(FileName);
+ exception.setErrMessage("Catch ClassNotFoundException.");
+ userLogger.error("41006 Exception occured: " + ex.getMessage());
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11021 UserManager::loadFromFile() throws FileNotReadException out exception=\"" + exception.toString() + "\"");
+ }
+ // --- debug log (out method) ---
+ throw exception;
+ }
+
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11022 UserManager::loadFromFile() throws FileNotReadException out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ /**
+ *
+ * <p>
+ * authUser method
+ * </p>
+ *
+ * @param userid
+ * @param userpass
+ * @return
+ */
+ public UserData authUser(String userid, String userpass) {
+ // --- debug log (in method) ---
+ Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE);
+ if (userLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("UserManager::authUser(String userid, String userpass) in ");
+ buf.append("userid=\"" + userid + "\", ");
+ buf.append("userpass=\"" + userpass + "\"");
+ userLogger.debug("11023 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ UserData ret = null;
+ if (userid != null || userpass != null) {
+ for (UserData data : uservec) {
+ if (data.userName.equals(userid) && data.passwd.equals(userpass)) {
+ ret = data;
+ break;
+ }
+ }
+ }
+
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("UserManager::authUser(String userid, String userpass) out ");
+ buf.append("return=(" + ret + ")");
+ userLogger.debug("11024 " + buf.toString());
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ *
+ * <p>
+ * closeUser method
+ * </p>
+ *
+ * @param request
+ */
+ public void closeUser(HttpServletRequest request) {
+ // --- debug log (in method) ---
+ Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE);
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11025 UserManager::closeUser(HttpServletRequest request) in request=(" + request +")");
+ }
+ // --- debug log (in method) ---
+
+ if (request != null) {
+ HttpSession session = request.getSession();
+ if (session != null) {
+ session.invalidate();
+ }
+ }
+
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11026 UserManager::closeUser(HttpServletRequest request) out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ /**
+ * check userid in userlist
+ *
+ * @param userid
+ * @return
+ */
+ public UserData findUser(String userid) {
+ // --- debug in (out method) ---
+ Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE);
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11027 UserManager::findUser(String userid) in userid=\"" + userid + "\"");
+ }
+ // --- debug log (in method) ---
+
+ UserData ret = null;
+ if (userid != null) {
+ for (UserData data : uservec) {
+ if (data.userName.equals(userid)) {
+ ret = data;
+ }
+ }
+ }
+
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11028 UserManager::findUser(String userid) out return=(" + ret + ")");
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+ /**
+ * user data add in UserDatas
+ *
+ * @param userid
+ * userid
+ * @param password
+ * password
+ * @param acl
+ * @param description
+ * @throws Exception
+ * UserData can't write
+ */
+ public boolean addUser(String userid, String password, int acl,
+ String description) throws FileNotWriteException {
+ // --- debug log (in method) ---
+ Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE);
+ if (userLogger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("UserManager::addUser(String userid, String password, int acl, String description) throws FileNotWriteException in ");
+ buf.append("userid=\"" + userid + "\", ");
+ buf.append("password=\"" + password + "\", ");
+ buf.append("acl=" + acl + ", ");
+ buf.append("description=\"" + description + "\"");
+ userLogger.debug("11029 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ if (userid == null || password == null || description == null) {
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11030 UserManager::addUser(String userid, String password, int acl, String description) throws FileNotWriteException out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+ UserData data = findUser(userid);
+ if (data == null) {
+ data = new UserData();
+ data.userName = userid;
+ data.passwd = password;
+ data.acl = acl;
+ data.description = description;
+ this.deepCopy();
+ uservec.add(data);
+ this.saveToFile();
+ } else {
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11031 UserManager::addUser(String userid, String password, int acl, String description) throws FileNotWriteException out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11032 UserManager::addUser(String userid, String password, int acl, String description) throws FileNotWriteException out return=true");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+
+ /**
+ *
+ * <p>
+ * changeUser method
+ * </p>
+ *
+ * @param data
+ * @return
+ * @throws FileNotWriteException
+ */
+ public boolean changeUser(UserData data) throws FileNotWriteException {
+ // --- debug log (in method) ---
+ Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE);
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11033 UserManager::changeUser(UserData data) throws FileNotWriteException in data=(" + data + ")");
+ }
+ // --- debug log (in method) ---
+
+ if (data == null) {
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11034 UserManager::changeUser(UserData data) throws FileNotWriteException out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+ UserData found = findUser(data.userName);
+ if (found != null) {
+ this.deepCopy();
+ found.passwd = data.passwd;
+ found.acl = data.acl;
+ found.description = data.description;
+ this.saveToFile();
+ } else {
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11035 UserManager::changeUser(UserData data) throws FileNotWriteException out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11036 UserManager::changeUser(UserData data) throws FileNotWriteException out return=true");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+
+ /**
+ * user data delete from UserDatas
+ *
+ * @param userid
+ * @throws Exception
+ */
+ public boolean delUser(String userid) throws FileNotWriteException {
+ // --- debug log (in method) ---
+ Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE);
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11037 UserManager::delUser(String userid) throws FileNotWriteException in userid=\"" + userid + "\"");
+ }
+ // --- debug log (in method) ---
+
+ if (userid == null) {
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11038 UserManager::delUser(String userid) throws FileNotWriteException out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+ UserData data = findUser(userid);
+ if (data != null && uservec.size() > 1) {
+ this.deepCopy();
+ uservec.remove(data);
+ this.saveToFile();
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11039 UserManager::delUser(String userid) throws FileNotWriteException out return=true");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11040 UserManager::delUser(String userid) throws FileNotWriteException out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ /**
+ *
+ * <p>
+ * getUserList method
+ * </p>
+ *
+ * @return
+ */
+ public Vector<UserData> getUserList() throws FileNotReadException {
+ // --- debug log (in/out method) ---
+ Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE);
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11041 UserManager::getUserList() in");
+ userLogger.debug("11042 UserManager::getUserList() out return=(" + uservec + ")");
+ }
+ // --- debug log (in/out method) ---
+ this.loadFromFile();
+
+ return this.uservec;
+ }
+
+ /**
+ *
+ * <p>
+ * setUserList method
+ * </p>
+ */
+ public void setUserList(Vector<UserData> uservec) throws FileNotWriteException {
+ // --- debug log (in method) ---
+ Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE);
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11043 UserManager::setUserList(Vector<UserData> uservec) in uservec=(" + uservec + ")");
+ }
+ // --- debug log (in method) ---
+
+ this.deepCopy();
+ this.uservec = uservec;
+ this.saveToFile();
+
+ // --- debug log (out method) ---
+ if (userLogger.isDebugEnabled()) {
+ userLogger.debug("11044 UserManager::setUserList(Vector<UserData> uservec) out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ protected void deepCopy() {
+ this.olduservec = new Vector<UserData>();
+ for (UserData cur : this.uservec) {
+ UserData copy = new UserData(cur);
+ olduservec.add(copy);
+ }
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+/**
+ * <p>class ButtonMode</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author kubota
+ */
+public interface ButtonMode {
+ public static final String APPLY = "Apply";
+ public static final String SAVE = "Save";
+ public static final String SAVESYNC = "Save + Sync";
+ public static final String SWITCH_OVER = "SwitchOver";
+ public static final String REP_MASTER_RUNNING = "Master Run";
+ public static final String REP_MASTER_STOPPING = "Master Stop";
+ public static final String REP_SLAVE_RUNNING = "Slave Run";
+ public static final String REP_SLAVE_STOPPING = "Slave Stop";
+ public static final String REP_EXECUTE = "Execute";
+ public static final String CHANGE = "Change";
+ public static final String ADD = "Add";
+ public static final String MODIFY = "Modify";
+ public static final String REMOVE = "Remove";
+ public static final String DELETE = "Delete";
+ public static final String YES = "Yes";
+
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.Serializable;
+import java.util.HashSet;
+
+import javax.servlet.http.HttpSession;
+
+import org.ultramonkey.l7.controller.*;
+import org.ultramonkey.l7.model.*;
+
+public class CommandExecuter extends Thread implements Serializable {
+ static final long serialVersionUID = 1L;
+
+ ExecuteMode mode;
+
+ Object DataClass;
+
+ Object OrgDataClass;
+
+ Object NewDataClass;
+
+ HttpSession session;
+
+ public CommandExecuter(HttpSession session) {
+ this.session = session;
+ this.mode = null;
+ this.DataClass = null;
+ this.OrgDataClass = null;
+ this.NewDataClass = null;
+
+ }
+
+ private void setThreadStatus(MessageView mv) {
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, mv);
+ }
+
+ private void setThreadStatus(String st) {
+ session.setAttribute(SessionKeys.THREAD_STATUS, st);
+ }
+
+ private void setThreadStatus(String st, String mes) {
+ session.setAttribute(SessionKeys.THREAD_STATUS, st);
+ }
+
+ public void setExecute(ExecuteMode mode, DirectorData DataClass)
+ throws IllegalArgumentException {
+ if (DataClass == null) {
+ throw (new IllegalArgumentException(
+ "Exception DirectorData is null."));
+ }
+ this.mode = mode;
+ this.DataClass = DataClass;
+ }
+
+ public void setExecute(ExecuteMode mode, VirtualSetting DataClass)
+ throws IllegalArgumentException {
+ if (DataClass == null) {
+ throw (new IllegalArgumentException(
+ "Exception VirtualSettingData is null."));
+ }
+ this.mode = mode;
+ this.DataClass = DataClass;
+
+ }
+
+ public void setExecute(ExecuteMode mode, VirtualSetting OrgDataClass,
+ VirtualSetting NewDataClass) throws IllegalArgumentException {
+ if (OrgDataClass == null || NewDataClass == null) {
+ throw (new IllegalArgumentException(
+ "Exception VirtualSettingData is null."));
+ }
+
+ this.mode = mode;
+ this.OrgDataClass = OrgDataClass;
+ this.NewDataClass = NewDataClass;
+ }
+
+ public void setExecute(ExecuteMode mode) {
+ this.mode = mode;
+ }
+
+ public void setExecute(ExecuteMode mode, ReplicationData DataClass) {
+ if (DataClass == null) {
+ throw (new IllegalArgumentException(
+ "Exception ReplicationData is null."));
+ }
+ this.mode = mode;
+ this.DataClass = DataClass;
+ }
+
+ public void setExecute(ExecuteMode mode, LogData DataClass) {
+ if (DataClass == null) {
+ throw (new IllegalArgumentException("Exception LogDeta is null."));
+ }
+ this.mode = mode;
+ this.DataClass = DataClass;
+
+ }
+
+ public void setExecute(ExecuteMode mode, SnmpAgentData DataClass) {
+ if (DataClass == null) {
+ throw (new IllegalArgumentException(
+ "Exception SnmpAgentData is null."));
+ }
+ this.mode = mode;
+ this.DataClass = DataClass;
+
+ }
+
+ public void setExecute(ExecuteMode mode, HashSet DataClass) {
+ if (DataClass == null) {
+ throw (new IllegalArgumentException(
+ "Exception categoryList is null."));
+ }
+ this.mode = mode;
+ this.DataClass = DataClass;
+
+ }
+
+ private boolean vsRemove(DirectorData dd, VirtualSetting vs) {
+ int i;
+ for (i = 0; i < dd.virtualSettings.size(); i++) {
+ if (vs.isSameService(dd.virtualSettings.elementAt(i))) {
+ dd.virtualSettings.remove(i);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean vsRemove(L7vsAdmData ad, VirtualSetting vs) {
+ int i;
+ for (i = 0; i < ad.virtualSettings.size(); i++) {
+ if (vs.isSameService(ad.virtualSettings.elementAt(i))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void run() {
+ boolean result = false;
+ boolean sameVs = false;
+ String message = "";
+ int errno = 0;
+ HashSet cset = new HashSet();
+ DirectorData dd;
+ L7vsAdmData ad;
+ setThreadStatus(SessionKeys.THREAD_RUNNING);
+ L7guiFramework framework = new L7guiFramework();
+ L7vsConfController confController = new L7vsConfController();
+ switch (this.mode) {
+ case DIRECTOR_SAVE:
+ String syntax = framework.checkDirectorData((DirectorData) this.DataClass);
+ if (syntax == null || !syntax.matches("^Syntax OK\n$")) {
+ errno = 41099;
+ if (syntax == null)
+ message = Message.WRITE_ERROR_L7DIRECTORD;
+ else {
+ String[] error = syntax.split("at line \\d+: ", 2);
+ if (error.length == 2)
+ message = Message.DIRECTOR_SYNTAX_ERROR + ": \"" + error[1] + "\"";
+ else
+ message = Message.DIRECTOR_SYNTAX_ERROR + " \"" + syntax + "\"";
+ }
+ result = false;
+ break;
+ }
+ else if (!(result = framework
+ .setDirectorData((DirectorData) this.DataClass))) {
+ errno = 41100;
+ message = Message.WRITE_ERROR_L7DIRECTORD;
+ break;
+ }
+ errno = 21049;
+ message = Message.DIRECTOR_SAVE;
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE);
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC);
+ session.setAttribute(SessionKeys.MONITOR_SYNC_STATE, SessionKeys.NO_SYNC);
+ break;
+
+ case DIRECTOR_SAVESYNC:
+ syntax = framework.checkDirectorData((DirectorData) this.DataClass);
+ if (syntax == null || !syntax.matches("^Syntax OK\n$")) {
+ errno = 41101;
+ if (syntax == null)
+ message = Message.WRITE_ERROR_L7DIRECTORD;
+ else {
+ String[] error = syntax.split("at line \\d+: ", 2);
+ if (error.length == 2)
+ message = Message.DIRECTOR_SYNTAX_ERROR + ": \"" + error[1] + "\"";
+ else
+ message = Message.DIRECTOR_SYNTAX_ERROR + "\"" + syntax + "\"";
+ }
+ result = false;
+ break;
+ }
+ else if (!(result = framework
+ .setDirectorData((DirectorData) this.DataClass))) {
+ errno = 41102;
+ message = Message.WRITE_ERROR_L7DIRECTORD;
+ break;
+ }
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE);
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC);
+ session.setAttribute(SessionKeys.MONITOR_SYNC_STATE, SessionKeys.NO_SYNC);
+ cset.add(SyncCategoryIdSet.MONITOR_ID);
+ if (!(result = framework.syncExecute(cset))) {
+ errno = 41103;
+ message = Message.SYNC_ERROR_L7DIRECTORD;
+ break;
+ }
+ errno = 21050;
+ message = Message.DIRECTOR_SAVESYNC;
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.SYNC);
+ session.setAttribute(SessionKeys.MONITOR_SYNC_STATE, SessionKeys.SYNC);
+ break;
+
+ case VS_ADD_APPLY: //
+ if (!(result = framework
+ .addVirtualSetting((VirtualSetting) this.DataClass))) {
+ errno = 41104;
+ message = Message.L7VSADM_ERROR;
+ break;
+ }
+ errno = 21051;
+ message = Message.VS_ADD_APPLY;
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.NO_SAVE);
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC);
+ break;
+
+ case VS_ADD_SAVE: //
+ // SAVE
+ if ((dd = framework.getDirectorData()) == null) {
+ errno = 41105;
+ message = Message.DIRECTOR_DATA_ERROR;
+ result = false;
+ break;
+ }
+ for (VirtualSetting exist : dd.virtualSettings) {
+ if (exist.isSameService((VirtualSetting) DataClass)) {
+ sameVs = true;
+ break;
+ }
+ }
+ if (sameVs == true) {
+ errno = 41106;
+ message = Message.VIRTUAL_SERVER_EXIST;
+ result = false;
+ break;
+ }
+ dd.virtualSettings.add((VirtualSetting) this.DataClass);
+ syntax = framework.checkDirectorData(dd);
+ if (syntax == null || !syntax.matches("^Syntax OK\n$")) {
+ errno = 41107;
+ if (syntax == null)
+ message = Message.WRITE_ERROR_L7DIRECTORD;
+ else {
+ String[] error = syntax.split("at line \\d+: ", 2);
+ if (error.length == 2)
+ message = Message.DIRECTOR_SYNTAX_ERROR + ": \"" + error[1] + "\"";
+ else
+ message = Message.DIRECTOR_SYNTAX_ERROR + "\"" + syntax + "\"";
+ }
+ result = false;
+ break;
+ }
+ else if (!(result = framework.setDirectorData(dd))) {
+ errno = 41108;
+ message = Message.WRITE_ERROR_L7DIRECTORD;
+ break;
+ }
+ errno = 21052;
+ message = Message.VS_ADD_SAVE;
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE);
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC);
+ break;
+
+ case VS_ADD_SAVESYNC: //
+ // SAVE
+ if ((dd = framework.getDirectorData()) == null) {
+ errno = 41109;
+ message = Message.DIRECTOR_DATA_ERROR;
+ result = false;
+ break;
+ }
+ for (VirtualSetting exist : dd.virtualSettings) {
+ if (exist.isSameService((VirtualSetting) DataClass)) {
+ sameVs = true;
+ break;
+ }
+ }
+ if (sameVs == true) {
+ errno = 41110;
+ message = Message.VIRTUAL_SERVER_EXIST;
+ result = false;
+ break;
+ }
+ dd.virtualSettings.add((VirtualSetting) this.DataClass);
+ syntax = framework.checkDirectorData(dd);
+ if (syntax == null || !syntax.matches("^Syntax OK\n$")) {
+ errno = 41111;
+ if (syntax == null)
+ message = Message.WRITE_ERROR_L7DIRECTORD;
+ else {
+ String[] error = syntax.split("at line \\d+: ", 2);
+ if (error.length == 2)
+ message = Message.DIRECTOR_SYNTAX_ERROR + ": \"" + error[1] + "\"";
+ else
+ message = Message.DIRECTOR_SYNTAX_ERROR + "\"" + syntax + "\"";
+ }
+ result = false;
+ break;
+ }
+ else if (!(result = framework.setDirectorData(dd))) {
+ errno = 41112;
+ message = Message.WRITE_ERROR_L7DIRECTORD;
+ break;
+ }
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE);
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC);
+ // SYNC
+ cset.add(SyncCategoryIdSet.SERVICE_ID);
+ if (!(result = framework.syncExecute(cset))) {
+ errno = 41113;
+ message = Message.SYNC_ERROR_L7DIRECTORD;
+ break;
+ }
+ errno = 21053;
+ message = Message.VS_ADD_SAVESYNC;
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.SYNC);
+ break;
+
+ case VS_REMOVE_APPLY: //
+ if (!(result = framework
+ .delVirtualSetting((VirtualSetting) this.DataClass))) {
+ errno = 41114;
+ message = Message.L7VSADM_ERROR;
+ break;
+ }
+ errno = 21054;
+ message = Message.VS_REMOVE_APPLY;
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.NO_SAVE);
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC);
+ break;
+
+ case VS_REMOVE_SAVE: //
+ // SAVE
+ if ((dd = framework.getDirectorData()) == null) {
+ errno = 41115;
+ message = Message.DIRECTOR_DATA_ERROR;
+ result = false;
+ break;
+ }
+ if ((ad = framework.getAdmData()) == null) {
+ errno = 41116;
+ message = Message.L7VSADM_ERROR;
+ result = false;
+ break;
+ }
+ result = this.vsRemove(dd, (VirtualSetting) this.DataClass);
+ syntax = framework.checkDirectorData(dd);
+ if (syntax == null || !syntax.matches("^Syntax OK\n$")) {
+ errno = 41117;
+ if (syntax == null)
+ message = Message.WRITE_ERROR_L7DIRECTORD;
+ else {
+ String[] error = syntax.split("at line \\d+: ", 2);
+ if (error.length == 2)
+ message = Message.DIRECTOR_SYNTAX_ERROR + ": \"" + error[1] + "\"";
+ else
+ message = Message.DIRECTOR_SYNTAX_ERROR + "\"" + syntax + "\"";
+ }
+ result = false;
+ break;
+ }
+ if (result == false) {
+ if(!(result = this.vsRemove(ad, (VirtualSetting) this.DataClass))) {
+ errno = 41118;
+ message = Message.NO_VS;
+ break;
+ } else if (!(result = framework.delVirtualSetting((VirtualSetting) this.DataClass))) {
+ errno = 41119;
+ message = Message.L7VSADM_ERROR;
+ break;
+ }
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.NO_SAVE);
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC);
+ }
+ if (!(result = framework.setDirectorData(dd))) {
+ errno = 41120;
+ message = Message.WRITE_ERROR_L7DIRECTORD;
+ break;
+ }
+ errno = 21055;
+ message = Message.VS_REMOVE_SAVE;
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE);
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC);
+ break;
+
+ case VS_REMOVE_SAVESYNC: //
+ // SAVE
+ if ((dd = framework.getDirectorData()) == null) {
+ errno = 41121;
+ message = Message.DIRECTOR_DATA_ERROR;
+ result = false;
+ break;
+ }
+ if ((ad = framework.getAdmData()) == null) {
+ errno = 41122;
+ message = Message.L7VSADM_ERROR;
+ result = false;
+ break;
+ }
+ result = this.vsRemove(dd, (VirtualSetting) this.DataClass);
+ syntax = framework.checkDirectorData(dd);
+ if (syntax == null || !syntax.matches("^Syntax OK\n$")) {
+ errno = 41123;
+ if (syntax == null)
+ message = Message.WRITE_ERROR_L7DIRECTORD;
+ else {
+ String[] error = syntax.split("at line \\d+: ", 2);
+ if (error.length == 2)
+ message = Message.DIRECTOR_SYNTAX_ERROR + ": \"" + error[1] + "\"";
+ else
+ message = Message.DIRECTOR_SYNTAX_ERROR + "\"" + syntax + "\"";
+ }
+ result = false;
+ break;
+ }
+ if (result == false) {
+ if(!(result = this.vsRemove(ad, (VirtualSetting) this.DataClass))) {
+ errno = 41124;
+ message = Message.NO_VS;
+ break;
+ } else if (!(result = framework.delVirtualSetting((VirtualSetting) this.DataClass))) {
+ errno = 41125;
+ message = Message.L7VSADM_ERROR;
+ break;
+ }
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.NO_SAVE);
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC);
+ }
+ if (!(result = framework.setDirectorData(dd))) {
+ errno = 41126;
+ message = Message.WRITE_ERROR_L7DIRECTORD;
+ break;
+ }
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE);
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC);
+
+ // SYNC
+ cset.add(SyncCategoryIdSet.SERVICE_ID);
+ if (!(result = framework.syncExecute(cset))) {
+ errno = 41127;
+ message = Message.SYNC_ERROR_L7DIRECTORD;
+ break;
+ }
+ errno = 21056;
+ message = Message.VS_REMOVE_SAVESYNC;
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.SYNC);
+ break;
+
+ case VS_MODIFY_APPLY: //
+ if (!(result = framework
+ .delVirtualSetting((VirtualSetting) this.OrgDataClass))) {
+ errno = 41128;
+ message = Message.L7VSADM_ERROR;
+ break;
+ }
+ if (!(result = framework
+ .addVirtualSetting((VirtualSetting) this.NewDataClass))) {
+ errno = 41129;
+ message = Message.L7VSADM_ERROR;
+ break;
+ }
+ errno = 21057;
+ message = Message.VS_MODIFY_APPLY;
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.NO_SAVE);
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC);
+ break;
+
+ case VS_MODIFY_SAVE: //
+ if ((dd = framework.getDirectorData()) == null) {
+ errno = 41130;
+ message = Message.DIRECTOR_DATA_ERROR;
+ result = false;
+ break;
+ }
+ if ((ad = framework.getAdmData()) == null) {
+ errno = 41131;
+ message = Message.L7VSADM_ERROR;
+ result = false;
+ break;
+ }
+ result = this.vsRemove(dd, (VirtualSetting) this.OrgDataClass);
+ for (VirtualSetting exist : dd.virtualSettings) {
+ if (exist.isSameService((VirtualSetting) NewDataClass)) {
+ sameVs = true;
+ break;
+ }
+ }
+ if (sameVs == true) {
+ errno = 41132;
+ message = Message.VIRTUAL_SERVER_EXIST;
+ result = false;
+ break;
+ }
+ dd.virtualSettings.add((VirtualSetting) this.NewDataClass);
+ syntax = framework.checkDirectorData(dd);
+ if (syntax == null || !syntax.matches("^Syntax OK\n$")) {
+ errno = 41133;
+ if (syntax == null)
+ message = Message.WRITE_ERROR_L7DIRECTORD;
+ else {
+ String[] error = syntax.split("at line \\d+: ", 2);
+ if (error.length == 2)
+ message = Message.DIRECTOR_SYNTAX_ERROR + ": \"" + error[1] + "\"";
+ else
+ message = Message.DIRECTOR_SYNTAX_ERROR + "\"" + syntax + "\"";
+ }
+ result = false;
+ break;
+ }
+ if (result == false) {
+ if(!(result = this.vsRemove(ad, (VirtualSetting) this.OrgDataClass))) {
+ errno = 41134;
+ message = Message.NO_VS;
+ break;
+ } else if (!(result = framework.delVirtualSetting((VirtualSetting) this.OrgDataClass))) {
+ errno = 41135;
+ message = Message.L7VSADM_ERROR;
+ break;
+ }
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.NO_SAVE);
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC);
+ }
+ if (!(result = framework.setDirectorData(dd))) {
+ errno = 41136;
+ message = Message.WRITE_ERROR_L7DIRECTORD;
+ break;
+ }
+ errno = 21058;
+ message = Message.VS_MODIFY_SAVE;
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE);
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC);
+ break;
+
+ case VS_MODIFY_SAVESYNC: //
+ if ((dd = framework.getDirectorData()) == null) {
+ errno = 41137;
+ message = Message.DIRECTOR_DATA_ERROR;
+ result = false;
+ break;
+ }
+ if ((ad = framework.getAdmData()) == null) {
+ errno = 41138;
+ message = Message.L7VSADM_ERROR;
+ result = false;
+ break;
+ }
+ result = this.vsRemove(dd, (VirtualSetting) this.OrgDataClass);
+ for (VirtualSetting exist : dd.virtualSettings) {
+ if (exist.isSameService((VirtualSetting) NewDataClass)) {
+ sameVs = true;
+ break;
+ }
+ }
+ if (sameVs == true) {
+ errno = 41139;
+ message = Message.VIRTUAL_SERVER_EXIST;
+ result = false;
+ break;
+ }
+ dd.virtualSettings.add((VirtualSetting) this.NewDataClass);
+ syntax = framework.checkDirectorData(dd);
+ if (syntax == null || !syntax.matches("^Syntax OK\n$")) {
+ errno = 41140;
+ if (syntax == null)
+ message = Message.WRITE_ERROR_L7DIRECTORD;
+ else {
+ String[] error = syntax.split("at line \\d+: ", 2);
+ if (error.length == 2)
+ message = Message.DIRECTOR_SYNTAX_ERROR + ": \"" + error[1] + "\"";
+ else
+ message = Message.DIRECTOR_SYNTAX_ERROR + "\"" + syntax + "\"";
+ }
+ result = false;
+ break;
+ }
+ if (result == false) {
+ if(!(result = this.vsRemove(ad, (VirtualSetting) this.OrgDataClass))) {
+ errno = 41141;
+ message = Message.NO_VS;
+ break;
+ } else if (!(result = framework.delVirtualSetting((VirtualSetting) this.OrgDataClass))) {
+ errno = 41142;
+ message = Message.L7VSADM_ERROR;
+ break;
+ }
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.NO_SAVE);
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC);
+ }
+ if (!(result = framework.setDirectorData(dd))) {
+ errno = 41143;
+ message = Message.WRITE_ERROR_L7DIRECTORD;
+ break;
+ }
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE);
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC);
+ // SYNC
+ cset.add(SyncCategoryIdSet.SERVICE_ID);
+ if (!(result = framework.syncExecute(cset))) {
+ errno = 41144;
+ message = Message.SYNC_ERROR_L7DIRECTORD;
+ break;
+ }
+ errno = 21059;
+ message = Message.VS_MODIFY_SAVESYNC;
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.SYNC);
+ break;
+
+ case CLUSTER_SWITCHORVER: //
+ if (!(result = framework.setClusterMode())) {
+ errno = 41145;
+ message = Message.CLUSTER_COMMAND_ERROR;
+ } else {
+ errno = 21060;
+ message = Message.CLUSTER_SWITCHORVER;
+ }
+ break;
+
+ case REP_MASTER: //
+ if (!(result = framework
+ .setReplicationMode(ReplicationStatus.MASTER))) {
+ errno = 41146;
+ message = Message.L7VSADM_ERROR;
+ } else {
+ errno = 21061;
+ message = Message.REP_MASTER;
+ }
+ break;
+
+ case REP_MASTER_STOP: //
+ if (!(result = framework
+ .setReplicationMode(ReplicationStatus.MASTER_STOP))) {
+ errno = 41147;
+ message = Message.L7VSADM_ERROR;
+ } else {
+ errno = 21062;
+ message = Message.REP_MASTER_STOP;
+ }
+ break;
+
+ case REP_SLAVE: //
+ if (!(result = framework
+ .setReplicationMode(ReplicationStatus.SLAVE))) {
+ errno = 41148;
+ message = Message.L7VSADM_ERROR;
+ } else {
+ errno = 21063;
+ message = Message.REP_SLAVE;
+ }
+ break;
+
+ case REP_SLAVE_STOP: //
+ if (!(result = framework
+ .setReplicationMode(ReplicationStatus.SLAVE_STOP))) {
+ errno = 41149;
+ message = Message.L7VSADM_ERROR;
+ } else {
+ errno = 21064;
+ message = Message.REP_SLAVE_STOP;
+ }
+ break;
+
+ case REP_INFO_SAVE: //
+ if (!(result = framework
+ .setReplicationData((ReplicationData) DataClass))) {
+ errno = 41150;
+ message = Message.WRITE_ERROR_L7VS;
+ } else {
+ errno = 21065;
+ message = Message.REP_INFO_SAVE;
+ session.setAttribute(SessionKeys.REP_SYNC_STATE, SessionKeys.NO_SYNC);
+ }
+ break;
+
+ case REP_INFO_SAVESYNC: //
+ if (result = framework
+ .setReplicationData((ReplicationData) DataClass)) {
+ session.setAttribute(SessionKeys.REP_SYNC_STATE, SessionKeys.NO_SYNC);
+ // SYNC
+ cset.add(SyncCategoryIdSet.REPLICATION_INFO_ID);
+ if (!(result = framework.syncExecute(cset))) {
+ errno = 41151;
+ message = Message.SYNC_ERROR_L7VS;
+ } else {
+ errno = 21066;
+ message = Message.REP_INFO_SAVESYNC;
+ session.setAttribute(SessionKeys.REP_SYNC_STATE, SessionKeys.SYNC);
+ }
+ } else {
+ errno = 41152;
+ message = Message.WRITE_ERROR_L7VS;
+ }
+ break;
+
+ case REP_START://
+ if (!(result = framework.dumpReplicationData())) {
+ errno = 41153;
+ message = Message.L7VSADM_ERROR;
+ } else {
+ errno = 21067;
+ message = Message.REP_START;
+ }
+ break;
+
+ case LOGLEVEL_CHANGE_APPLY:
+ LogData ld = (LogData) DataClass;
+ if (! (result = framework.setLogLevel(ld.lbLog.logLevel))) {
+ errno = 41154;
+ message = Message.L7VSADM_ERROR;
+ }
+ else if (! (result = framework.setLogLevel(ld.snmpLog.logLevel))) {
+ errno = 41155;
+ message = Message.L7VSADM_ERROR;
+ } else {
+ errno = 21068;
+ message = Message.LOGLEVEL_CHANGE_APPLY;
+ session.setAttribute(SessionKeys.LOG_SAVE_STATE, SessionKeys.NO_SAVE);
+ session.setAttribute(SessionKeys.LOG_SYNC_STATE, SessionKeys.NO_SYNC);
+ }
+ break;
+
+ case LOGLEVEL_CHANGE_SAVE: //
+ try {
+ L7vsConfData cf = confController.getConfData();
+ cf.logger = (LogData) DataClass;
+ if (! (result = framework.setL7vsConfData(cf))) {
+ errno = 41156;
+ message = Message.WRITE_ERROR_L7VS;
+ } else if (! (result = framework.reloadAdmData(L7vsConfCategory.LOGGER))) {
+ errno = 41157;
+ message = Message.L7VSADM_ERROR;
+ } else if (! (result = framework.reloadAdmData(L7vsConfCategory.SNMPAGENT))) {
+ errno = 41158;
+ message = Message.L7VSADM_ERROR;
+ } else {
+ errno = 21069;
+ message = Message.LOGLEVEL_CHANGE_SAVE;
+ session.setAttribute(SessionKeys.LOG_SAVE_STATE, SessionKeys.SAVE);
+ session.setAttribute(SessionKeys.LOG_SYNC_STATE, SessionKeys.NO_SYNC);
+ }
+ } catch (Exception e) {
+ errno = 41159;
+ message = Message.L7VS_CONF_DATA_ERROR;
+ result = false;
+ }
+ break;
+
+ case LOGLEVEL_CHANGE_SAVESYNC: //
+ try {
+ L7vsConfData cf = confController.getConfData();
+ cf.logger = (LogData) DataClass;
+ if (! (result = framework.setL7vsConfData(cf))) {
+ errno = 41160;
+ message = Message.WRITE_ERROR_L7VS;
+ } else if (! (result = framework.reloadAdmData(L7vsConfCategory.LOGGER))) {
+ errno = 41161;
+ message = Message.L7VSADM_ERROR;
+ } else if (! (result = framework.reloadAdmData(L7vsConfCategory.SNMPAGENT))) {
+ errno = 41162;
+ message = Message.L7VSADM_ERROR;
+ } else {
+ session.setAttribute(SessionKeys.LOG_SAVE_STATE, SessionKeys.SAVE);
+ session.setAttribute(SessionKeys.LOG_SYNC_STATE, SessionKeys.NO_SYNC);
+ cset.add(SyncCategoryIdSet.LOG_ALL_ID);
+ if (! (result = framework.syncExecute(cset))) {
+ errno = 41163;
+ message = Message.SYNC_ERROR_L7VS;
+ } else {
+ errno = 21070;
+ message = Message.LOGLEVEL_CHANGE_SAVESYNC;
+ session.setAttribute(SessionKeys.LOG_SYNC_STATE, SessionKeys.SYNC);
+ }
+ }
+ } catch (Exception e) {
+ errno = 41164;
+ message = Message.L7VS_CONF_DATA_ERROR;
+ result = false;
+ }
+ break;
+
+ case SNMP_INFO_SAVE: //
+ if (!(result = framework
+ .setSnmpAgentData((SnmpAgentData) DataClass))) {
+ errno = 41165;
+ message = Message.WRITE_ERROR_L7VS;
+ } else {
+ errno = 21071;
+ message = Message.SNMP_INFO_SAVE;
+ session.setAttribute(SessionKeys.SNMP_SYNC_STATE, SessionKeys.NO_SYNC);
+ }
+ break;
+
+ case SNMP_INFO_SAVESYNC: //
+ if (!(result = framework
+ .setSnmpAgentData((SnmpAgentData) DataClass))) {
+ errno = 41166;
+ message = Message.WRITE_ERROR_L7VS;
+ break;
+ }
+ session.setAttribute(SessionKeys.SNMP_SYNC_STATE, SessionKeys.NO_SYNC);
+ // SYNC
+ cset.add(SyncCategoryIdSet.SNMP_INFO_ID);
+ if (!(result = framework.syncExecute(cset))) {
+ errno = 41167;
+ message = Message.SYNC_ERROR_L7VS;
+ } else {
+ errno = 21072;
+ message = Message.SNMP_INFO_SAVESYNC;
+ session.setAttribute(SessionKeys.SNMP_SYNC_STATE, SessionKeys.SYNC);
+ }
+ break;
+
+ case SYNC: //
+ HashSet<Integer> syncSet = (HashSet<Integer>) DataClass;
+ if (!(result = framework.syncExecute(syncSet))) {
+ errno = 41168;
+ message = Message.SYNC_FAIL;
+ } else {
+ errno = 21073;
+ message = Message.SYNC;
+ for (int i : syncSet) {
+ switch(i) {
+ case SyncCategoryIdSet.L7VSD_LOG_ID:
+ case SyncCategoryIdSet.ADM_LOG_ID:
+ case SyncCategoryIdSet.SNMP_LOG_ID:
+ case SyncCategoryIdSet.LOG_ALL_ID:
+ session.setAttribute(SessionKeys.LOG_SYNC_STATE, SessionKeys.SYNC);
+ break;
+ case SyncCategoryIdSet.REPLICATION_INFO_ID:
+ session.setAttribute(SessionKeys.REP_SYNC_STATE, SessionKeys.SYNC);
+ break;
+ case SyncCategoryIdSet.SNMP_INFO_ID:
+ session.setAttribute(SessionKeys.SNMP_SYNC_STATE, SessionKeys.SYNC);
+ break;
+ case SyncCategoryIdSet.MONITOR_ID:
+ session.setAttribute(SessionKeys.MONITOR_SYNC_STATE, SessionKeys.SYNC);
+ break;
+ case SyncCategoryIdSet.SERVICE_ID:
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.SYNC);
+ break;
+ case SyncCategoryIdSet.USERDATA_ID:
+ session.setAttribute(SessionKeys.GUI_SYNC_STATE, SessionKeys.SYNC);
+ case SyncCategoryIdSet.ADM_INFO_ID:
+ default:
+ }
+ }
+ }
+ break;
+
+ default:
+ throw (new IllegalArgumentException("Illegal Parameter."));
+ }
+ MessageView mv = new MessageView();
+ mv.setCategory(LogCategorySet.GUI_IO_COMMAND);
+ mv.setMessage(message);
+ mv.setErrno(errno);
+ setThreadStatus(mv);
+
+ if (result != true) {
+ setThreadStatus(SessionKeys.THREAD_FAIL);
+ } else {
+ setThreadStatus(SessionKeys.THREAD_SUCCESS);
+ }
+ return;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.*;
+
+/**
+ * servlet base class
+ *
+ * @author nakai
+ * @version 1.0
+ * @since 1.0
+ */
+public class L7guiServletBase extends HttpServlet {
+ static final long serialVersionUID = 1L;
+ protected static final String USERPARAM = "uid";
+ protected static final String PASSWDPARAM = "passwd";
+ protected boolean login = false;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ public L7guiServletBase() {
+ super();
+
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11339 class L7guiServletBase created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /* (non-Java-doc)
+ * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7guiServletBase::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11340 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ doPost(request, response);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11341 L7guiServletBase::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ /* (non-Java-doc)
+ * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+ *
+ * ex. child class
+ * public class childServlet extends L7guiServletBase {
+ * protected void doPost(HttpServletRequest req, HttpServletResponse res) {
+ * super.doPost(req, res);
+ * if ( login == false ) return;
+ * :
+ * :
+ * :
+ * }
+ * }
+ */
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7guiServletBase::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11342 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ HttpSession session = request.getSession(false);
+ login = this.checkSession(session);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11343 L7guiServletBase::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ }
+
+ /*
+ *
+ * <p> checkSession method</p>
+ *
+ * @param session
+ * @return
+ */
+ public boolean checkSession(HttpSession session){
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("L7guiServletBase::checkSession(HttpSession session) in ");
+ buf.append("session=(" + session + ")");
+ logger.debug("11344 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ // session check.
+ if (session == null) {
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11345 L7guiServletBase::checkSession(HttpSession session) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ UserData sessionUserData = (UserData) session.getAttribute(SessionKeys.LOGIN_SESSION);
+ UserManager userManager = UserManager.getInstance();
+
+ try {
+ UserData serverUserData = userManager.authUser(sessionUserData.userName, sessionUserData.passwd);
+ if (serverUserData == null) {
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11346 L7guiServletBase::checkSession(HttpSession session) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+ } catch (NullPointerException e) {
+ logger.error("41086 Exception occured: " + e.getMessage());
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11347 L7guiServletBase::checkSession(HttpSession session) out return=false");
+ }
+ // --- debug log (out method) ---
+ return false;
+ }
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11348 L7guiServletBase::checkSession(HttpSession session) out return=true");
+ }
+ // --- debug log (out method) ---
+ return true;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import java.util.*;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.controller.*;
+import org.ultramonkey.l7.model.*;
+
+
+/**
+ * <p>class LogLevelServlet</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author tsubone
+ */
+public class LogLevelServlet extends L7guiServletBase {
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public LogLevelServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11467 class LogLevelServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("LogLevelServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11468 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11469 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11470 LogLevelServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11471 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11472 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ /*
+ * check login session
+ */
+ super.doPost(request, response);
+
+ HttpSession session = request.getSession(false);
+ if (login == false || session == null) {
+ if (session != null) {
+ MessageView error = new MessageView(41203, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ }
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11473 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * get logSetInfo
+ */
+ request.setCharacterEncoding("UTF-8");
+ HashMap<String, String[]> tmpMap = (HashMap<String, String[]>) request
+ .getParameterMap();
+ if (tmpMap == null) {
+ MessageView error = new MessageView(41204, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11474 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ HashMap<String, String> inputLogLevelMap = new HashMap<String, String>();
+ Iterator i = tmpMap.keySet().iterator();
+ while (i.hasNext()) {
+ String key = (String) i.next();
+ inputLogLevelMap.put(key, tmpMap.get(key)[0]);
+ }
+
+ String logType = (String) inputLogLevelMap.get("type");
+ if (logType == null) {
+ MessageView error = new MessageView(41205, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11475 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ HashMap<LogData.LogCategory, LogData.LogLevel> logLevelList = null;
+
+ L7guiFramework frame = new L7guiFramework();
+ LogData logInfo = frame.getLogData();
+ if (logInfo == null) {
+ MessageView error = new MessageView(41206, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11476 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ SessionTransData pagetrans = new SessionTransData();
+ String level = null;
+ LogData.LogLevel logLevel = null;
+ boolean levelCheckFlag = true;
+
+ try {
+ if (logType.equals(LogCategorySet.L7VSD)) {
+ logLevelList = logInfo.lbLog.logLevel;
+ pagetrans.sourceURI = RedirectPages.LOG_L7VSD;
+ pagetrans.destURI = RedirectPages.LOG_L7VSD;
+ pagetrans.errorURI = RedirectPages.LOG_L7VSD;
+ session.setAttribute(SessionKeys.PAGE_TRANSDATA, pagetrans);
+
+ level = inputLogLevelMap.get("L7VSD_NETWORK");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_NETWORK, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_NETWORK_BANDWIDTH");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_NETWORK_BANDWIDTH,
+ logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_NETWORK_NUM_CONNECTION");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_NETWORK_NUM_CONNECTION,
+ logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_NETWORK_QOS");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_NETWORK_QOS, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_VIRTUAL_SERVICE");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_VIRTUAL_SERVICE, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_REAL_SERVER");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_REAL_SERVER, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_SORRY_SERVER");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_SORRY_SERVER, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_REAL_SERVER_BALANCING");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_REAL_SERVER_BALANCING,
+ logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_REPLICATION");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_REPLICATION, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_START_STOP");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_START_STOP, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_SYSTEM");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_SYSTEM, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_SYSTEM_MEMORY");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_SYSTEM_MEMORY, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_SYSTEM_SOCKET");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_SYSTEM_SOCKET, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_SYSTEM_SIGNAL");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_SYSTEM_SIGNAL, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_ENVIRONMENT");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_ENVIRONMENT, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_ENVIRONMENT_PARAMETER");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_ENVIRONMENT_PARAMETER,
+ logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_LOGGER");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_LOGGER, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_PARAMETER");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_PARAMETER, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_EVENT");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_EVENT, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_SCHEDULE");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_SCHEDULE, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_PROGRAM");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_PROGRAM, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_PROTOCOL");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_PROTOCOL, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSD_MODULE");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSD_MODULE, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ } else if (logType.equals(LogCategorySet.L7VSADM)) {
+ logLevelList = logInfo.admLog.logLevel;
+ pagetrans.sourceURI = RedirectPages.LOG_L7VSADM;
+ pagetrans.destURI = RedirectPages.LOG_L7VSADM;
+ pagetrans.errorURI = RedirectPages.LOG_L7VSADM;
+ session.setAttribute(SessionKeys.PAGE_TRANSDATA, pagetrans);
+
+ level = inputLogLevelMap.get("L7VSADM_PARSE");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSADM_PARSE, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSADM_OPERATE");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSADM_OPERATE, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSADM_COMMUNICATE");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSADM_COMMUNICATE, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSADM_CONFIG_RESULT");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSADM_CONFIG_RESULT, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSADM_COMMON");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSADM_COMMON, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSADM_LOGGER");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSADM_LOGGER, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSADM_PARAMETER");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSADM_PARAMETER, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSADM_PROTOCOL");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSADM_PROTOCOL, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("L7VSADM_MODULE");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.L7VSADM_MODULE, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ } else if (logType.equals(LogCategorySet.SNMPAGENT)) {
+ logLevelList = logInfo.snmpLog.logLevel;
+ pagetrans.sourceURI = RedirectPages.LOG_SNMPAGENT;
+ pagetrans.destURI = RedirectPages.LOG_SNMPAGENT;
+ pagetrans.errorURI = RedirectPages.LOG_SNMPAGENT;
+ session.setAttribute(SessionKeys.PAGE_TRANSDATA, pagetrans);
+
+ level = inputLogLevelMap.get("SNMPAGENT_START_STOP");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.SNMPAGENT_START_STOP, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("SNMPAGENT_MANAGER_RECEIVE");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.SNMPAGENT_MANAGER_RECEIVE,
+ logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("SNMPAGENT_MANAGER_SEND");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.SNMPAGENT_MANAGER_SEND,
+ logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("SNMPAGENT_L7VSD_RECEIVE");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.SNMPAGENT_L7VSD_RECEIVE,
+ logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("SNMPAGENT_L7VSD_SEND");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.SNMPAGENT_L7VSD_SEND, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("SNMPAGENT_LOGGER");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.SNMPAGENT_LOGGER, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ level = inputLogLevelMap.get("SNMPAGENT_PARAMETER");
+ logLevel = levelCheck(level);
+ if (logLevel != null) {
+ logLevelList.put(LogData.LogCategory.SNMPAGENT_PARAMETER, logLevel);
+ } else {
+ levelCheckFlag = false;
+ }
+ } else if (logType.equals(LogCategorySet.L7GUI)) {
+ logLevelList = logInfo.guiLog.logLevel;
+ pagetrans.sourceURI = RedirectPages.LOG_L7GUI;
+ pagetrans.destURI = RedirectPages.LOG_L7GUI;
+ pagetrans.errorURI = RedirectPages.LOG_L7GUI;
+ session.setAttribute(SessionKeys.PAGE_TRANSDATA, pagetrans);
+ } else if (logType.equals(LogCategorySet.GUI_SYNC)) {
+ logLevelList = logInfo.syncLog.logLevel;
+ pagetrans.sourceURI = RedirectPages.LOG_SYNC;
+ pagetrans.destURI = RedirectPages.LOG_SYNC;
+ pagetrans.errorURI = RedirectPages.LOG_SYNC;
+ session.setAttribute(SessionKeys.PAGE_TRANSDATA, pagetrans);
+ } else {
+ MessageView error = new MessageView(41207, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11477 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ } catch (NullPointerException e) {
+ MessageView error = new MessageView(41208, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11478 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ if (levelCheckFlag == false) {
+ MessageView error = new MessageView(21090, LogCategorySet.GUI_LOG, Message.VALIDATION_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ session.setAttribute(SessionKeys.INPUT_LOGLEVEL, logInfo);
+ response.sendRedirect(pagetrans.sourceURI);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11479 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * choice button mode, commandExecute mode
+ */
+ CommandExecuter thread = new CommandExecuter(session);
+
+ String redirectPage;
+ ExecuteMode mode;
+ String button_mode = inputLogLevelMap.get("button");
+
+ // button mode : apply
+ if (button_mode != null && button_mode.equals(ButtonMode.APPLY)) {
+ mode = ExecuteMode.LOGLEVEL_CHANGE_APPLY;
+ redirectPage = RedirectPages.LOG_LEVEL_EXECUTIVE;
+ }
+
+ // button mode : save
+ else if (button_mode != null && button_mode.equals(ButtonMode.SAVE)) {
+ mode = ExecuteMode.LOGLEVEL_CHANGE_SAVE;
+ redirectPage = RedirectPages.LOG_LEVEL_EXECUTIVE;
+ }
+
+ // button mode : save and sync
+ else if (button_mode != null && button_mode.equals(ButtonMode.SAVESYNC)) {
+ mode = ExecuteMode.LOGLEVEL_CHANGE_SAVESYNC;
+ redirectPage = RedirectPages.SAVE_SYNC_EXECUTIVE;
+ } else {
+ MessageView error = new MessageView(41209, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11480 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ try {
+ thread.setExecute(mode, logInfo);
+ thread.start();
+ } catch (Exception e) {
+ MessageView error = new MessageView(41210, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11481 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ response.sendRedirect(redirectPage);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11482 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+
+ }
+
+ /**
+ *
+ * <p> levelCheck method</p>
+ *
+ * @param level
+ * @return
+ */
+ private LogData.LogLevel levelCheck(String level) {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11483 LogLevelServlet::levelCheck(String level) in level=\"" + level + "\"");
+ }
+ // --- debug log (in method) ---
+
+ LogData.LogLevel ret = null;
+ if (level == null) {
+ ret = null;
+ } else if (level.equals("NONE")) {
+ ret = LogData.LogLevel.NONE;
+ } else if (level.equals("DEBUG")) {
+ ret = LogData.LogLevel.DEBUG;
+ } else if (level.equals("ERROR")) {
+ ret = LogData.LogLevel.ERROR;
+ } else if (level.equals("WARN")) {
+ ret = LogData.LogLevel.WARN;
+ } else if (level.equals("FATAL")) {
+ ret = LogData.LogLevel.FATAL;
+ } else if (level.equals("INFO")) {
+ ret = LogData.LogLevel.INFO;
+ }
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11484 LogLevelServlet::levelCheck(String level) out return=" + ret);
+ }
+ // --- debug log (out method) ---
+ return ret;
+ }
+
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.SocketException;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.*;
+import org.ultramonkey.l7.controller.*;
+
+/**
+ *
+ * <p>
+ * class LogOutputServlet
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author kubota
+ */
+public class LogOutputServlet extends org.ultramonkey.l7.view.L7guiServletBase {
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public LogOutputServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11363 class LoginServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("LogOutputServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11364 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11365 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ // check login session
+ super.doPost(request, response);
+
+ HttpSession session = request.getSession(false);
+ if (login == false || session == null) {
+ if (session != null) {
+ MessageView error = new MessageView(41093, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ }
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11366 LogOutputServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ request.setCharacterEncoding("UTF-8");
+ String logType = request.getParameter("type");
+ String logFile = request.getParameter("log");
+
+ if (logType == null || logFile == null) {
+ MessageView error = new MessageView(41094, LogCategorySet.GUI_LOG,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11367 LogOutputServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ Vector<LogFileData> logList = null;
+
+ L7guiFramework frameWork = new L7guiFramework();
+ LogData log = frameWork.getLogData();
+
+ try {
+ if (logType.equals(LogCategorySet.L7VSD)) {
+ logList = log.lbLog.logFiles;
+ } else if (logType.equals(LogCategorySet.L7VSADM)) {
+ logList = log.admLog.logFiles;
+ } else if (logType.equals(LogCategorySet.L7DIRECTORD)) {
+ logList = log.directorLog.logFiles;
+ } else if (logType.equals(LogCategorySet.SNMPAGENT)) {
+ logList = log.snmpLog.logFiles;
+ } else if (logType.equals(LogCategorySet.L7GUI)) {
+ logList = log.guiLog.logFiles;
+ } else if (logType.equals(LogCategorySet.SYNC)) {
+ logList = log.syncLog.logFiles;
+ } else if (logType.equals(LogCategorySet.HA)) {
+ logList = log.haLog.logFiles;
+ } else {
+ MessageView error = new MessageView(41095, LogCategorySet.GUI_LOG,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11368 LogOutputServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ } catch (NullPointerException e) {
+ MessageView error = new MessageView(41096, LogCategorySet.GUI_LOG,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11369 LogOutputServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ if (logList == null) {
+ MessageView error = new MessageView(41097, LogCategorySet.GUI_LOG,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11370 LogOutputServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ String dwLogFilePath = null;
+ boolean matchFlag = false;
+
+ for (int i = 0; i < logList.size(); i++) {
+ if (logList.get(i).fileName.equals(logFile)) {
+ dwLogFilePath = logList.get(i).filePath;
+ matchFlag = true;
+ break;
+ }
+ }
+ if ((matchFlag == false) || (dwLogFilePath == null)) {
+ MessageView error = new MessageView(41098, LogCategorySet.GUI_LOG,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11371 LogOutputServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ // Log File DownLoad
+ File file = new File(dwLogFilePath);
+ BufferedInputStream in = null;
+ BufferedOutputStream out = null;
+ try {
+ // HTTP HEADER OUT
+ response.setContentType("application/octet-stream");
+ response.setHeader("Content-Disposition", "attachment; filename=\""
+ + file.getName() + "\"");
+ response.setContentLength((int) file.length());
+
+ in = new BufferedInputStream(new FileInputStream(file));
+ out = new BufferedOutputStream(response.getOutputStream());
+
+ byte buf[] = new byte[1024];
+ int len;
+
+ while ((len = in.read(buf)) != -1) {
+ out.write(buf, 0, len);
+ }
+ } catch (SocketException e) {
+ // nothing to do
+ } catch (Exception e) {
+ // HTTP HEADER RESET
+ response.reset();
+ response.sendError(HttpURLConnection.HTTP_INTERNAL_ERROR, e.toString());
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ if (out != null) {
+ out.flush();
+ out.close();
+ }
+ }
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11372 LogOutputServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("LogOutputServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11373 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11374 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11375 LogOutputServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.*;
+import org.ultramonkey.l7.controller.*;
+
+/**
+ * Servlet implementation class for Servlet: Login
+ *
+ */
+public final class LoginServlet extends L7guiServletBase implements Servlet {
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public LoginServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11279 class LoginServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("LoginServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11280 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11281 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11282 LoginServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11283 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11284 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ boolean validationFlag = true;
+ HttpSession session = request.getSession(true);
+ if (session == null) {
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11285 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ request.setCharacterEncoding("UTF-8");
+ String userName = request.getParameter("uid");
+ String userPass = request.getParameter("passwd");
+
+ if ( (userName == null) || (userPass == null) ){
+ MessageView error = new MessageView(41066, LogCategorySet.GUI_USER_MANAGE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11286 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+
+ // UserID,Password validationCheck
+ validationFlag = validationCheck(userName, userPass);
+ if (false == validationFlag) {
+ MessageView error = new MessageView(21039, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.USERID_PASSWORD_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11287 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ UserManager manager = UserManager.getInstance();
+ if (manager == null) {
+ MessageView error = new MessageView(41067, LogCategorySet.GUI_START_STOP, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11288 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ UserData user = manager.authUser(userName, userPass);
+ if (user != null) {
+ Parameter param = Parameter.getInstance();
+ if (param == null) {
+ MessageView error = new MessageView(41068, LogCategorySet.GUI_START_STOP,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11289 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ String sessionTimeout = param.getValue(Parameter.SESSION_TIMEOUT);
+ if (sessionTimeout != null) {
+ try{
+ session.setMaxInactiveInterval(Integer
+ .parseInt(sessionTimeout));
+ }catch(Exception e){
+ MessageView error = new MessageView(41069, LogCategorySet.GUI_START_STOP,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11290 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ }
+
+ session.setAttribute(SessionKeys.LOGIN_SESSION, user);
+ } else {
+ MessageView error = new MessageView(41070, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.USER_AUTH_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11291 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ // Session Key Initialize
+ session.setAttribute(SessionKeys.LOG_SYNC_STATE, SessionKeys.SYNC);
+ session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.SYNC);
+ session.setAttribute(SessionKeys.MONITOR_SYNC_STATE, SessionKeys.SYNC);
+ session.setAttribute(SessionKeys.REP_SYNC_STATE, SessionKeys.SYNC);
+ session.setAttribute(SessionKeys.SNMP_SYNC_STATE, SessionKeys.SYNC);
+ session.setAttribute(SessionKeys.GUI_SYNC_STATE, SessionKeys.SYNC);
+
+ // Get Data
+ L7guiFramework framework = new L7guiFramework();
+ L7vsAdmData admDataList = framework.getAdmData();
+ DirectorData directorData = framework.getDirectorData();
+ L7vsConfData confData = framework.getL7vsConfData();
+
+
+ if (admDataList == null || directorData == null || confData == null) {
+ MessageView error = new MessageView(41071, LogCategorySet.GUI_IO, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11292 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ boolean vsSave = false;
+ if (admDataList.virtualSettings.size() == directorData.virtualSettings.size()) {
+ for (int i = 0; i < admDataList.virtualSettings.size(); i++) {
+ VirtualSetting admVs = admDataList.virtualSettings.elementAt(i);
+ for (int j = 0; j < directorData.virtualSettings.size(); j++) {
+ VirtualSetting directorVs = directorData.virtualSettings.elementAt(j);
+ if (vsSave = directorVs.equalsAdm(admVs))
+ break;
+ }
+ if (vsSave == false)
+ break;
+ }
+ if (admDataList.virtualSettings.size() == 0)
+ vsSave = true;
+ }
+ if (vsSave == true) {
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE);
+ } else {
+ session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.NO_SAVE);
+ }
+
+ try{
+ boolean logL7vsdSave = true;
+ boolean logSnmpSave = true;
+
+ // l7vsdLog compare
+ HashMap<LogData.LogCategory, LogData.LogLevel> admL7vsdLogLevel = admDataList.l7vsdLogLevel;
+ HashMap<LogData.LogCategory, LogData.LogLevel> confL7vsdLogLevel = confData.logger.lbLog.logLevel;
+ logL7vsdSave = admL7vsdLogLevel.equals(confL7vsdLogLevel);
+
+ // SNMPLog compare
+ HashMap<LogData.LogCategory, LogData.LogLevel> admSnmpLogLevel = admDataList.snmpLogLevel;
+ HashMap<LogData.LogCategory, LogData.LogLevel> confSnmpLogLevel = confData.logger.snmpLog.logLevel;
+ logSnmpSave = admSnmpLogLevel.equals(confSnmpLogLevel);
+
+ // compare logData
+ if ((logL7vsdSave == true) && (logSnmpSave == true)) {
+ session.setAttribute(SessionKeys.LOG_SAVE_STATE, SessionKeys.SAVE);
+ } else {
+ session.setAttribute(SessionKeys.LOG_SAVE_STATE,
+ SessionKeys.NO_SAVE);
+ }
+ }catch(NullPointerException e){
+ MessageView error = new MessageView(41072, LogCategorySet.GUI_USER_MANAGE, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11293 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ response.sendRedirect(RedirectPages.TOPMENU);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11294 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /**
+ *
+ * <p>
+ * validationCheck method
+ * </p>
+ *
+ * @param userName
+ * @param userPass
+ * @return validationFlag : true/false
+ */
+ private boolean validationCheck(String userName, String userPass) {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("LoginServlet::validationCheck(String userName, String userPass) in ");
+ buf.append("userName=\"" + userName + "\", ");
+ buf.append("userPass=\"" + userPass + "\"");
+ logger.debug("11295 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ boolean validationFlag = true;
+ final int MIN_LENGTH = 1;
+ final int MAX_LENGTH = 16;
+ final int MIN_PASS_LENGTH = 6;
+
+ if ((userName.length() < MIN_LENGTH)
+ || (userName.length() > MAX_LENGTH)) {
+ validationFlag = false;
+ } else if ((userPass.length() < MIN_PASS_LENGTH)
+ || (userPass.length() > MAX_LENGTH)) {
+ validationFlag = false;
+ }
+
+ else {
+ Pattern pattern = Pattern.compile("([^\\x20-\\x7e])");
+ Matcher userNameMatcher = pattern.matcher(userName);
+ Matcher userPassMatcher = pattern.matcher(userPass);
+
+ if (userNameMatcher.find() || userPassMatcher.find()) {
+ validationFlag = false;
+ }
+ }
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11296 LoginServlet::validationCheck(String userName, String userPass) out return=" + validationFlag);
+ }
+ // --- debug log (in method) ---
+ return validationFlag;
+ }
+
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.controller.*;
+import org.ultramonkey.l7.model.*;
+
+/**
+ * <p>
+ * class MonitorSetServlet
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ * <p>
+ * Servlet implementation class for Servlet: MonitorSet
+ * </p>
+ *
+ * @author tsubone
+ */
+public class MonitorSetServlet extends L7guiServletBase {
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public MonitorSetServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11485 class MonitorSetServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("MonitorServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11486 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11487 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger
+ .debug("11488 MonitorServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("MonitorServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11489 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11490 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ /*
+ * check login session
+ */
+ super.doPost(request, response);
+
+ HttpSession session = request.getSession(false);
+ if (login == false || session == null) {
+ if (session != null) {
+ MessageView error = new MessageView(41211,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ }
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger
+ .debug("11491 MonitorServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * get MonitorInfo
+ */
+ request.setCharacterEncoding("UTF-8");
+ HashMap<String, String[]> tmpMap = (HashMap<String, String[]>) request
+ .getParameterMap();
+ if (tmpMap == null) {
+ MessageView error = new MessageView(41212, LogCategorySet.GUI_IO_FILE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger
+ .debug("11492 MonitorServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ HashMap<String, String> inputMonitorMap = new HashMap<String, String>();
+ Iterator i = tmpMap.keySet().iterator();
+ while (i.hasNext()) {
+ String key = (String) i.next();
+ inputMonitorMap.put(key, tmpMap.get(key)[0]);
+ }
+
+ L7guiFramework frame = new L7guiFramework();
+ DirectorData monitorInfo = frame.getDirectorData();
+
+ if (monitorInfo == null) {
+ MessageView error = new MessageView(41213, LogCategorySet.GUI_IO_FILE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger
+ .debug("11493 MonitorServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * validation check
+ */
+ boolean validationFlag = true;
+ HashMap<String, String> invalidMap = new HashMap<String, String>();
+
+ validationFlag = validationCheck(inputMonitorMap, invalidMap,
+ monitorInfo);
+
+ if (validationFlag == false) {
+ MessageView error = new MessageView(21091, LogCategorySet.GUI_MONITOR,
+ Message.VALIDATION_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ session.setAttribute(SessionKeys.INPUT_MONITOR, monitorInfo);
+ session.setAttribute(SessionKeys.INVALID_MESSAGE, invalidMap);
+
+ response.sendRedirect(RedirectPages.MONITOR_MODIFY);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger
+ .debug("11494 MonitorServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * choice button mode, commandExecute mode
+ */
+ CommandExecuter thread = new CommandExecuter(session);
+
+ ExecuteMode mode;
+ String redirectPage;
+
+ String button_mode = inputMonitorMap.get("button");
+
+ // button mode : save
+ if (button_mode != null && button_mode.equals(ButtonMode.SAVE)) {
+ mode = ExecuteMode.DIRECTOR_SAVE;
+ redirectPage = RedirectPages.MONITOR_MODIFY_EXECUTIVE;
+ }
+
+ // button mode : save and sync
+ else if (button_mode != null && button_mode.equals(ButtonMode.SAVESYNC)) {
+ mode = ExecuteMode.DIRECTOR_SAVESYNC;
+ redirectPage = RedirectPages.SAVE_SYNC_EXECUTIVE;
+
+ SessionTransData trans = new SessionTransData();
+ trans.sourceURI = RedirectPages.MONITOR_MODIFY;
+ trans.destURI = RedirectPages.MONITOR_INFO;
+ trans.errorURI = RedirectPages.MONITOR_MODIFY_NG;
+ session.setAttribute(SessionKeys.PAGE_TRANSDATA, trans);
+ } else {
+ MessageView error = new MessageView(41214, LogCategorySet.GUI_MONITOR,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger
+ .debug("11495 MonitorServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ try {
+ thread.setExecute(mode, monitorInfo);
+ thread.start();
+ } catch (Exception e) {
+ MessageView error = new MessageView(41215, LogCategorySet.GUI_MONITOR,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger
+ .debug("11496 MonitorServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ response.sendRedirect(redirectPage);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger
+ .debug("11497 MonitorServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /**
+ *
+ * <p>
+ * validationCheck method
+ * </p>
+ *
+ * @param inputMonitorMap
+ * @param invalidMap
+ * @param monitorInfo
+ * @return
+ */
+
+ protected boolean validationCheck(HashMap<String, String> inputMonitorMap,
+ HashMap<String, String> invalidMap, DirectorData monitorInfo) {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf
+ .append("MonitorSetServlet::validationCheck(HashMap<String, String> inputMonitorMap, HashMap<String, String> invalidMap, DirectorData monitorInfo) in ");
+ buf.append("inputMonitorMap=(" + inputMonitorMap + "), ");
+ buf.append("invalidMap=(" + invalidMap + "), ");
+ buf.append("monitorInfo=(" + monitorInfo + ")");
+ logger.debug("11498 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ boolean validationFrag = true;
+
+ final int MIN_CHECK_TIME_OUT = 1;
+ final int MAX_CHECK_TIME_OUT = Integer.MAX_VALUE;
+ final int MIN_NEGOTIATE_TIME_OUT = 1;
+ final int MAX_NEGOTIATE_TIME_OUT = Integer.MAX_VALUE;
+ final int MIN_CHECK_INTERVAL = 1;
+ final int MAX_CHECK_INTERVAL = Integer.MAX_VALUE;
+ final int MIN_CHECK_COUNT = 1;
+ final int MAX_CHECK_COUNT = Integer.MAX_VALUE;
+ final int CALLBACK_LENGTH = 127;
+ final int FALLBACK_LENGTH = 127;
+ final int LOGFILE_LENGTH = 127;
+ final int EXECUTE_LENGTH = 127;
+
+ // checkTimeOut validationCheck
+ String checkTimeOut = inputMonitorMap.get("checkTimeOut");
+ if (checkTimeOut != null && checkTimeOut.length() > 0) {
+ int int_checkTimeOut = 0;
+ try {
+ int_checkTimeOut = Integer.parseInt(checkTimeOut);
+ if ((int_checkTimeOut < MIN_CHECK_TIME_OUT)
+ || (int_checkTimeOut > MAX_CHECK_TIME_OUT)) {
+ invalidMap.put("checkTimeOut", Message.INVALID_VALUE);
+ validationFrag = false;
+ }
+ } catch (NumberFormatException e) {
+ invalidMap.put("checkTimeOut", Message.INVALID_VALUE);
+ validationFrag = false;
+ }
+ }
+ monitorInfo.checkTimeOut = checkTimeOut;
+
+ // negotiateTimeOut validationCheck
+ String negotiateTimeOut = inputMonitorMap.get("negotiateTimeOut");
+ if (negotiateTimeOut != null && negotiateTimeOut.length() > 0) {
+ int int_negotiateTimeOut = 0;
+ try {
+ int_negotiateTimeOut = Integer.parseInt(negotiateTimeOut);
+ if ((int_negotiateTimeOut < MIN_NEGOTIATE_TIME_OUT)
+ || (int_negotiateTimeOut > MAX_NEGOTIATE_TIME_OUT)) {
+ invalidMap.put("negotiateTimeOut", Message.INVALID_VALUE);
+ validationFrag = false;
+ }
+ } catch (NumberFormatException e) {
+ invalidMap.put("negotiateTimeOut", Message.INVALID_VALUE);
+ validationFrag = false;
+ }
+ }
+ monitorInfo.negotiateTimeOut = negotiateTimeOut;
+
+ // CheckInterval validationCheck
+ String checkInterval = inputMonitorMap.get("checkInterval");
+ if (checkInterval != null && checkInterval.length() > 0) {
+ int int_checkInterval = 0;
+ try {
+ int_checkInterval = Integer.parseInt(checkInterval);
+ if ((int_checkInterval < MIN_CHECK_INTERVAL)
+ || (int_checkInterval > MAX_CHECK_INTERVAL)) {
+ invalidMap.put("checkInterval", Message.INVALID_VALUE);
+ validationFrag = false;
+ }
+ } catch (NumberFormatException e) {
+ invalidMap.put("checkInterval", Message.INVALID_VALUE);
+ validationFrag = false;
+ }
+ }
+ monitorInfo.checkInterval = checkInterval;
+
+ // checkCount validationCheck
+ String checkCount = inputMonitorMap.get("checkCount");
+ if (checkCount != null && checkCount.length() > 0) {
+ int int_checkCount = 0;
+ try {
+ int_checkCount = Integer.parseInt(checkCount);
+ if ((int_checkCount < MIN_CHECK_COUNT)
+ || (int_checkCount > MAX_CHECK_COUNT)) {
+ invalidMap.put("checkCount", Message.INVALID_VALUE);
+ validationFrag = false;
+ }
+ } catch (NumberFormatException e) {
+ invalidMap.put("checkCount", Message.INVALID_VALUE);
+ validationFrag = false;
+ }
+ }
+ monitorInfo.checkCount = checkCount;
+
+ // callback validationCheck
+ String callback = inputMonitorMap.get("callback");
+ if (callback != null && callback.length() > 0) {
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+ Matcher matcher = pattern.matcher(callback);
+
+ if (callback.length() > CALLBACK_LENGTH || matcher.find()) {
+ invalidMap.put("callback", Message.INVALID_VALUE);
+ validationFrag = false;
+ }
+ }
+ monitorInfo.callback = callback;
+
+ // fallback validationCheck
+ String fallback = inputMonitorMap.get("fallback");
+ if (fallback != null && fallback.length() > 0) {
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+ Matcher matcher = pattern.matcher(fallback);
+
+ if (fallback.length() > FALLBACK_LENGTH || matcher.find()) {
+ invalidMap.put("fallback", Message.INVALID_VALUE);
+ validationFrag = false;
+ }
+ }
+ monitorInfo.fallback = fallback;
+
+ // logfile validationCheck
+ String logfile = inputMonitorMap.get("logfile");
+ if (logfile != null && logfile.length() > 0) {
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+ Matcher matcher = pattern.matcher(logfile);
+
+ if (logfile.length() > LOGFILE_LENGTH || matcher.find()) {
+ invalidMap.put("logfile", Message.INVALID_VALUE);
+ validationFrag = false;
+ }
+ }
+ monitorInfo.logfile = logfile;
+
+ // execute validationCheck
+ String execute = inputMonitorMap.get("execute");
+ if (execute != null && execute.length() > 0) {
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+ Matcher matcher = pattern.matcher(execute);
+
+ if (execute.length() > EXECUTE_LENGTH || matcher.find()) {
+ invalidMap.put("execute", Message.INVALID_VALUE);
+ validationFrag = false;
+ }
+ }
+ monitorInfo.execute = execute;
+
+ // supervised validationCheck
+ String supervised = inputMonitorMap.get("supervised");
+ if (supervised != null && supervised.length() > 0) {
+ if (!supervised.equals("yes") && !supervised.equals("no")) {
+ invalidMap.put("supervised", Message.INVALID_VALUE);
+ validationFrag = false;
+ }
+ }
+ monitorInfo.supervised = supervised;
+
+ // quiescent validationCheck
+ String quiescent = inputMonitorMap.get("quiescent");
+ if (quiescent != null && quiescent.length() > 0) {
+ if (!quiescent.equals("yes") && !quiescent.equals("no")) {
+ invalidMap.put("quiescent", Message.INVALID_VALUE);
+ validationFrag = false;
+ }
+ }
+ monitorInfo.quiescent = quiescent;
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11499 MonitorSetServlet::validationCheck(HashMap<String, String> inputMonitorMap, HashMap<String, String> invalidMap, DirectorData monitorInfo) return=" + validationFrag);
+ }
+ // --- debug log (out method) ---
+ return validationFrag;
+ }
+
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+public interface RedirectPages {
+ public static final String REFRESH_TIME = "3";
+
+ public static final String NOSCRIPT_TIME = "0";
+
+ public static final String LOGIN = "index.jsp";
+
+ public static final String TOPMENU = "top.jsp";
+
+ public static final String STATE_INFO = "um7state_info.jsp";
+
+ public static final String VS_ADD = "vs_add.jsp";
+
+ public static final String VS_ADD_NG = "vs_add_fail.jsp";
+
+ public static final String VS_ADD_EXECUTIVE = "vs_add_executive.jsp";
+
+ public static final String VS_MODIFY = "vs_modify.jsp";
+
+ public static final String VS_MODIFY_EXECUTIVE = "vs_modify_executive.jsp";
+
+ public static final String VS_MODIFY_NG = "vs_modify_fail.jsp";
+
+ public static final String VS_REMOVE_SUCCESS = "vs_remove.jsp";
+
+ public static final String VS_REMOVE_NG = "vs_remove_fail.jsp";
+
+ public static final String VS_REMOVE_EXECUTIVE = "vs_remove_executive.jsp";
+
+ public static final String LOG_LEVEL_EXECUTIVE = "log_level_executive.jsp";
+
+ public static final String LOG_L7VSD = "log_lb.jsp";
+
+ public static final String LOG_L7VSADM = "log_adm.jsp";
+
+ public static final String LOG_SNMPAGENT = "log_snmp.jsp";
+
+ public static final String LOG_L7GUI = "log_gui.jsp";
+
+ public static final String LOG_SYNC = "log_sync.jsp";
+
+ public static final String MONITOR_INFO = "monitor_info.jsp";
+
+ public static final String MONITOR_MODIFY = "monitor_modify.jsp";
+
+ public static final String MONITOR_MODIFY_EXECUTIVE = "monitor_modify_executive.jsp";
+
+ public static final String MONITOR_MODIFY_NG = "monitor_modify_fail.jsp";
+
+ public static final String SAVE_SYNC_EXECUTIVE = "savesync_executive.jsp";
+
+ public static final String SNMP_MODIFY = "snmp.jsp";
+
+ public static final String SNMP_MODIFY_EXECUTIVE = "snmp_modify_executive.jsp";
+
+ public static final String SNMP_MODIFY_NG = "snmp_modify_fail.jsp";
+
+ public static final String REPLICATION_INFO = "replication.jsp";
+
+ public static final String REPLICATION_MODIFY = "replication_modify.jsp";
+
+ public static final String REPLICATION_INFO_EXECUTIVE = "replication_modify_executive.jsp";
+
+ public static final String REPLICATION_MODIFY_NG = "replication_modify_fail.jsp";
+
+ public static final String REPLICATION_MODE_NG = "replication_mode_fail.jsp";
+
+ public static final String REPLICATION_MODE_EXECUTIVE = "replication_mode_executive.jsp";
+
+ public static final String REPLICATION_NG = "replication_fail.jsp";
+
+ public static final String REPLICATION_EXECUTIVE = "replication_executive.jsp";
+
+ public static final String SO_OK = "so_success.jsp";
+
+ public static final String SO_NG = "so_fail.jsp";
+
+ public static final String SO_EXECUTIVE = "so_executive.jsp";
+
+ public static final String SYNC = "sync.jsp";
+
+ public static final String SYNC_EXECUTIVE = "sync_executive.jsp";
+
+ public static final String SYNC_NG = "sync_fail.jsp";
+
+ public static final String USER_MODIFY = "user_modify.jsp";
+
+ /**
+ * @deprecated {@link #USER_MODIFY} �̑�p
+ */
+ public static final String PW_CHANGE = USER_MODIFY;
+
+ public static final String USER_MODIFY_SUCCESS = "user_modify_success.jsp";
+
+ public static final String USER_MODIFY_FAIL = "user_modify_fail.jsp";
+
+ public static final String USER_ADD = "user_add.jsp";
+
+ public static final String USER_MANAGE = "user_manage.jsp";
+
+ public static final String USER_ADD_FAIL = "user_add_fail.jsp";
+
+ public static final String USER_DELETE_FAIL = "user_delete_fail.jsp";
+
+ public static final String SAVE = "save.jsp";
+
+ public static final String SAVE_FAIL = "save_fail.jsp";
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.ExecuteMode;
+import org.ultramonkey.l7.model.L7guiFramework;
+import org.ultramonkey.l7.model.LogCategorySet;
+import org.ultramonkey.l7.model.Message;
+import org.ultramonkey.l7.model.MessageView;
+import org.ultramonkey.l7.model.SessionTransData;
+import org.ultramonkey.l7.controller.*;
+
+
+/**
+ *
+ * <p>class ReplicationInfoChangeServlet</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author kubota
+ */
+
+public class ReplicationInfoChangeServlet extends org.ultramonkey.l7.view.L7guiServletBase{
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public ReplicationInfoChangeServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11297 class ReplicationInfoChangeServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+ */
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("ReplicationInfoChangeServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11298 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11299 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11300 ReplicationInfoChangeServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("ReplicationInfoChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11301 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11302 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ // check login session
+ super.doPost(request, response);
+
+ HttpSession session = request.getSession(false);
+ if (login == false || session == null) {
+ if (session != null) {
+ MessageView error = new MessageView(41073, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ }
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11303 ReplicationInfoChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ L7guiFramework framework = new L7guiFramework();
+ ReplicationData rep = framework.getReplicationData();
+ if ( rep == null ){
+ MessageView error = new MessageView(41074, LogCategorySet.GUI_IO_FILE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11304 ReplicationInfoChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ request.setCharacterEncoding("UTF-8");
+ String str_repInterval = request.getParameter("rep_interval");
+ String str_beforeRepData = Integer.toString(rep.interval);
+
+ boolean validationFrag = validationCheck(session, str_repInterval, rep);
+ if (validationFrag == false ){
+ session.setAttribute(SessionKeys.INPUT_REP, rep);
+ MessageView error = new MessageView(21040, LogCategorySet.GUI_REPLICATION,
+ Message.INVALID_VALUE);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.REPLICATION_MODIFY);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11305 ReplicationInfoChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ CommandExecuter thread = new CommandExecuter(session);
+
+ ExecuteMode mode;
+ String redirectPage;
+
+ String button_mode = request.getParameter("button");
+
+ // button mode : save
+ if (button_mode != null && button_mode.equals(ButtonMode.SAVE)) {
+ mode = ExecuteMode.REP_INFO_SAVE;
+ redirectPage = RedirectPages.REPLICATION_INFO_EXECUTIVE;
+ }
+ // button mode : save and sync
+ else if (button_mode != null && button_mode.equals(ButtonMode.SAVESYNC)) {
+ mode = ExecuteMode.REP_INFO_SAVESYNC;
+ redirectPage = RedirectPages.SAVE_SYNC_EXECUTIVE;
+
+ SessionTransData trans = new SessionTransData();
+ trans.sourceURI = RedirectPages.REPLICATION_MODIFY;
+ trans.destURI = RedirectPages.REPLICATION_INFO;
+ trans.errorURI = RedirectPages.REPLICATION_MODIFY_NG;
+ session.setAttribute(SessionKeys.PAGE_TRANSDATA, trans);
+ }
+ else {
+ MessageView error = new MessageView(41075, LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11306 ReplicationInfoChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ try {
+ thread.setExecute(mode, rep);
+ thread.start();
+ }
+ catch(Exception e)
+ {
+ MessageView error = new MessageView(41076, LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11307 ReplicationInfoChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ session.setAttribute(SessionKeys.BEFORE_REP_TIME, str_beforeRepData);
+ String str_afterRepData = Integer.toString(rep.interval);
+ session.setAttribute(SessionKeys.AFTER_REP_TIME, str_afterRepData);
+ response.sendRedirect(redirectPage);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11308 ReplicationInfoChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /**
+ *
+ * <p> validationCheck method</p>
+ *
+ * @param session
+ * @param str_repInterval
+ * @param rep
+ * @return
+ */
+ protected boolean validationCheck(HttpSession session, String str_repInterval, ReplicationData rep ){
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("ReplicationInfoChangeServlet::validationCheck(HttpSession session, String str_repInterval, ReplicationData rep) in ");
+ buf.append("session=(" + session + "), ");
+ buf.append("str_repInterval=(" + str_repInterval + "), ");
+ buf.append("rep=(" + rep + ")");
+ logger.debug("11309 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ boolean validationFlag = true;
+
+ final int MIN_REP_INTERVAL = 10;
+ final int MAX_REP_INTERVAL = 10000;
+ int repInterval = 0;
+
+ if (session == null || rep == null) {
+ validationFlag = false;
+ } else if ( (str_repInterval == null) || str_repInterval.length() == 0){
+ session.setAttribute(SessionKeys.INVALID_MESSAGE, Message.REQUIED_ITEM);
+ validationFlag = false;
+ }
+ else {
+ try {
+ repInterval = Integer.parseInt(str_repInterval);
+ if ( (repInterval < MIN_REP_INTERVAL) || (repInterval > MAX_REP_INTERVAL) ) {
+ session.setAttribute(SessionKeys.INVALID_MESSAGE, Message.VALIDATION_ERROR);
+ validationFlag = false;
+ } else {
+ rep.interval = repInterval;
+ }
+ }
+ catch (NumberFormatException e) {
+ session.setAttribute(SessionKeys.INVALID_MESSAGE, Message.VALIDATION_ERROR);
+ validationFlag = false;
+ }
+ }
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11310 ReplicationInfoChangeServlet::validationCheck(HttpSession session, String str_repInterval, ReplicationData rep) out return=" + validationFlag);
+ }
+ // --- debug log (out method) ---
+ return validationFlag;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.*;
+
+/**
+ * Servlet implementation class for Servlet: ReplicationModeChangeServlet
+ *
+ */
+
+public class ReplicationModeChangeServlet extends L7guiServletBase {
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public ReplicationModeChangeServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11389 class ReplicationModeChangeServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("ReplicationModeChangeServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11390 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11391 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11392 ReplicationModeChangeServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("ReplicationModeChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11393 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11394 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ // check login session
+ super.doPost(request, response);
+
+ HttpSession session = request.getSession(false);
+ if (login == false || session == null) {
+ if (session != null) {
+ MessageView error = new MessageView(41174, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ }
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11395 ReplicationModeChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ ExecuteMode mode;
+ request.setCharacterEncoding("UTF-8");
+ String buttonMode = request.getParameter("button");
+ if (buttonMode == null){
+ MessageView error = new MessageView(41175, LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11396 ReplicationModeChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ if (buttonMode.equals(ButtonMode.REP_MASTER_RUNNING))
+ mode = ExecuteMode.REP_MASTER;
+ else if (buttonMode.equals(ButtonMode.REP_MASTER_STOPPING))
+ mode = ExecuteMode.REP_MASTER_STOP;
+ else if (buttonMode.equals(ButtonMode.REP_SLAVE_RUNNING))
+ mode = ExecuteMode.REP_SLAVE;
+ else if (buttonMode.equals(ButtonMode.REP_SLAVE_STOPPING))
+ mode = ExecuteMode.REP_SLAVE_STOP;
+ else{
+ MessageView error = new MessageView(41176, LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11397 ReplicationModeChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ CommandExecuter thread = new CommandExecuter(session);
+ try {
+ thread.setExecute(mode);
+ thread.start();
+ }
+ catch(Exception e) {
+ MessageView error = new MessageView(41177, LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11398 ReplicationModeChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ response.sendRedirect(RedirectPages.REPLICATION_MODE_EXECUTIVE);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11399 ReplicationModeChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.ExecuteMode;
+import org.ultramonkey.l7.model.LogCategorySet;
+import org.ultramonkey.l7.model.Message;
+import org.ultramonkey.l7.model.MessageView;
+
+/**
+ * Servlet implementation class for Servlet: ReplicationRunServlet
+ *
+ */
+ public class ReplicationRunServlet extends L7guiServletBase {
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public ReplicationRunServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11457 class ReplicationRunServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("ReplicationRunServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11458 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11459 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11460 ReplicationRunServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("ReplicationRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11461 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11462 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ // check login session
+ super.doPost(request, response);
+
+ HttpSession session = request.getSession(false);
+ if (login == false || session == null) {
+ if (session != null) {
+ MessageView error = new MessageView(41200, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ }
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11463 ReplicationRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ request.setCharacterEncoding("UTF-8");
+ String buttonMode = request.getParameter("button_immediate");
+ if ((buttonMode != null) && (buttonMode.equals(ButtonMode.REP_EXECUTE))) {
+ CommandExecuter thread = new CommandExecuter(session);
+ try {
+ thread.setExecute(ExecuteMode.REP_START);
+ thread.start();
+ }
+ catch(Exception e) {
+ MessageView error = new MessageView(41201, LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11464 ReplicationRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ }
+ else {
+ MessageView error = new MessageView(41202, LogCategorySet.GUI_REPLICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11465 ReplicationRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ response.sendRedirect(RedirectPages.REPLICATION_EXECUTIVE);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11466 ReplicationRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.HashSet;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.L7guiFramework;
+import org.ultramonkey.l7.model.LogCategorySet;
+import org.ultramonkey.l7.model.Message;
+import org.ultramonkey.l7.model.MessageView;
+import org.ultramonkey.l7.model.SaveCategoryIdSet;
+
+/**
+ * Servlet implementation class for Servlet: SaveStateServlet
+ *
+ */
+public class SaveStateServlet extends org.ultramonkey.l7.view.L7guiServletBase {
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ private enum status {
+ NO_SAVE, SAVE_OK, SAVE_NG
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public SaveStateServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11249 class SaveStateServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("SaveStateServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11250 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11251 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11252 SaveStateServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("SaveStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11253 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11254 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ // check login session
+ super.doPost(request, response);
+
+ HttpSession session = request.getSession(false);
+ if (login == false || session == null) {
+ if (session != null) {
+ MessageView error = new MessageView(41050, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ }
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11255 SaveStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ // get checkbox Category Data & button Mode
+ request.setCharacterEncoding("UTF-8");
+ String selectCheck[] = request.getParameterValues("save_category");
+ String button_mode = request.getParameter("button");
+ if (button_mode == null || button_mode.equals(ButtonMode.SAVE) == false) {
+ MessageView error = new MessageView(41051, LogCategorySet.GUI_SAVE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11256 SaveStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ if (selectCheck == null) {
+ MessageView error = new MessageView(21033, LogCategorySet.GUI_SAVE,
+ Message.SAVE_CATEGORY_SELECT_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.SAVE);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11257 SaveStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ status saveLogResult = status.NO_SAVE;
+ status saveVsResult = status.NO_SAVE;
+ String resultPage = RedirectPages.SAVE;
+
+ L7guiFramework framework = new L7guiFramework();
+
+ for (int i = 0; i < selectCheck.length; i++) {
+ if (selectCheck[i].equals("save_log")) {
+ HashSet<SaveCategoryIdSet> saveCategory = new HashSet<SaveCategoryIdSet>();
+ saveCategory.add(SaveCategoryIdSet.LOG_ID);
+
+ if (framework.saveExecute(saveCategory)) {
+ session.setAttribute(SessionKeys.LOG_SAVE_STATE,
+ SessionKeys.SAVE);
+ saveLogResult = status.SAVE_OK;
+ } else {
+ saveLogResult = status.SAVE_NG;
+ resultPage = RedirectPages.SAVE_FAIL;
+ }
+ } else if (selectCheck[i].equals("save_service")) {
+ HashSet<SaveCategoryIdSet> saveCategory = new HashSet<SaveCategoryIdSet>();
+
+ saveCategory.add(SaveCategoryIdSet.VS_ID);
+ if (framework.saveExecute(saveCategory)) {
+ session.setAttribute(SessionKeys.VS_SAVE_STATE,
+ SessionKeys.SAVE);
+ saveVsResult = status.SAVE_OK;
+ } else {
+ saveVsResult = status.SAVE_NG;
+ resultPage = RedirectPages.SAVE_FAIL;
+ }
+ } else {
+ MessageView error = new MessageView(41052, LogCategorySet.GUI_SAVE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11258 SaveStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ }
+
+ if (saveLogResult == status.SAVE_OK &&
+ saveVsResult == status.SAVE_OK) {
+ MessageView success = new MessageView(21034, LogCategorySet.GUI_SAVE,
+ Message.SAVE_LOG_VS_SUCCESS);
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, success);
+ } else if (saveLogResult == status.SAVE_OK
+ && saveVsResult == status.SAVE_NG) {
+ MessageView error = new MessageView(41053, LogCategorySet.GUI_SAVE, Message.SAVE_LOG_SUCCESS
+ + "<br />\n" + Message.SAVE_VS_FAIL);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ } else if (saveLogResult == status.SAVE_OK
+ && saveVsResult == status.NO_SAVE) {
+ MessageView success = new MessageView(21035, LogCategorySet.GUI_SAVE, Message.SAVE_LOG_SUCCESS);
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, success);
+ } else if (saveLogResult == status.SAVE_NG
+ && saveVsResult == status.SAVE_OK) {
+ MessageView error = new MessageView(41054, LogCategorySet.GUI_SAVE, Message.SAVE_LOG_FAIL
+ + "<br />\n" + Message.SAVE_VS_SUCCESS);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ } else if (saveLogResult == status.SAVE_NG
+ && saveVsResult == status.SAVE_NG) {
+ MessageView error = new MessageView(41055, LogCategorySet.GUI_SAVE, Message.SAVE_LOG_VS_FAIL);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ } else if (saveLogResult == status.SAVE_NG
+ && saveVsResult == status.NO_SAVE) {
+ MessageView error = new MessageView(41056, LogCategorySet.GUI_SAVE, Message.SAVE_LOG_FAIL);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ } else if (saveLogResult == status.NO_SAVE
+ && saveVsResult == status.SAVE_OK) {
+ MessageView success = new MessageView(21036, LogCategorySet.GUI_SAVE, Message.SAVE_VS_SUCCESS);
+ session.setAttribute(SessionKeys.COMMAND_MESSAGE, success);
+ } else if (saveLogResult == status.NO_SAVE
+ && saveVsResult == status.SAVE_NG) {
+ MessageView error = new MessageView(41057, LogCategorySet.GUI_SAVE, Message.SAVE_VS_FAIL);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ } else {
+ MessageView error = new MessageView(41058, LogCategorySet.GUI_SAVE, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11259 SaveStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ response.sendRedirect(resultPage);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11260 SaveStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+public interface SessionKeys {
+ public static final String LOGIN_SESSION = "onLogin";
+ public static final String RESULT_MESSAGE = "resultMessage";
+ public static final String COMMAND_MESSAGE = "commandMessage";
+ public static final String PAGE_TRANSDATA = "pageTrans";
+ public static final String OLD_VS = "oldVsData";
+ public static final String INPUT_VS = "inputVsData";
+ public static final String INPUT_REP = "inputRepData";
+ public static final String INPUT_SNMP = "inputSnmpAgentData";
+ public static final String INPUT_SNMP_UNIT = "unit_snmpInterval";
+ public static final String INPUT_LOGLEVEL = "inputLogLebel";
+ public static final String INPUT_MONITOR = "inputMonitorData";
+ public static final String INVALID_MESSAGE = "invalidMessage";
+ public static final String INPUT_USERDATA = "inputUserData";
+ public static final String VS_NAME = "vsName";
+ public static final String BEFORE_REP_TIME = "beforeRepTime";
+ public static final String AFTER_REP_TIME = "afterRepTime";
+
+ public static final String THREAD_STATUS = "threadStatus";
+ public static final String THREAD_SUCCESS = "success";
+ public static final String THREAD_FAIL = "fail";
+ public static final String THREAD_RUNNING = "running";
+
+ public static final String LOG_SAVE_STATE = "logSaveState";
+ public static final String VS_SAVE_STATE = "vsSaveState";
+ public static final String SAVE = "save";
+ public static final String NO_SAVE = "noSave";
+
+ public static final String LOG_SYNC_STATE = "logSyncState";
+ public static final String VS_SYNC_STATE = "vsSyncState";
+ public static final String MONITOR_SYNC_STATE = "monitorSyncState";
+ public static final String REP_SYNC_STATE = "repSyncState";
+ public static final String SNMP_SYNC_STATE = "snmpSyncState";
+ public static final String GUI_SYNC_STATE = "guiSyncState";
+ public static final String SYNC = "sync";
+ public static final String NO_SYNC = "noSync";
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.controller.SnmpAgentData;
+import org.ultramonkey.l7.model.ExecuteMode;
+import org.ultramonkey.l7.model.L7guiFramework;
+import org.ultramonkey.l7.model.LogCategorySet;
+import org.ultramonkey.l7.model.Message;
+import org.ultramonkey.l7.model.MessageView;
+import org.ultramonkey.l7.model.SessionTransData;
+
+/**
+ * <p>
+ * class VSModServlet
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author kobayashi
+ */
+public class SnmpAgentServlet extends org.ultramonkey.l7.view.L7guiServletBase {
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public SnmpAgentServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11261 class SnmpAgentServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("SnmpAgentServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11262 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11263 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11264 SnmpAgentServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11265 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11266 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ // check login session
+ super.doPost(request, response);
+
+ HttpSession session = request.getSession(false);
+ if (login == false || session == null) {
+ if (session != null) {
+ MessageView error = new MessageView(41059,
+ LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ }
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11267 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * get SnmpAgentData
+ */
+ request.setCharacterEncoding("UTF-8");
+ String str_snmpInterval = request.getParameter("snmp_interval");
+ if (str_snmpInterval == null) {
+ MessageView error = new MessageView(41060, LogCategorySet.GUI_SNMP,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11268 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ // unit_snmpInterval
+ String unit_snmpInterval = request.getParameter("unit_interval");
+ if (unit_snmpInterval == null) {
+ MessageView error = new MessageView(41061, LogCategorySet.GUI_SNMP,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11269 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ // SnmpAgetData
+ L7guiFramework frameWork = new L7guiFramework();
+ SnmpAgentData snmp = frameWork.getSnmpAgentData();
+ if (snmp == null) {
+ MessageView error = new MessageView(41062, LogCategorySet.GUI_SNMP,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11270 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * validationCheck
+ */
+ boolean validationFlag = validationcheck(session, str_snmpInterval,
+ snmp);
+ if (validationFlag == false) {
+ session.setAttribute(SessionKeys.INPUT_SNMP, snmp);
+ session
+ .setAttribute(SessionKeys.INPUT_SNMP_UNIT,
+ unit_snmpInterval);
+ MessageView error = new MessageView(21037, LogCategorySet.GUI_SNMP,
+ Message.INVALID_VALUE);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.SNMP_MODIFY);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11271 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * set unit_snmpInterval
+ */
+ if (unit_snmpInterval.equals("ms")) {
+ //
+ } else if (unit_snmpInterval.equals("s")) {
+ snmp.interval *= 1000;
+ } else {
+ session.setAttribute(SessionKeys.INPUT_SNMP, snmp);
+ session
+ .setAttribute(SessionKeys.INPUT_SNMP_UNIT,
+ unit_snmpInterval);
+ MessageView error = new MessageView(21038, LogCategorySet.GUI_SNMP,
+ Message.INVALID_VALUE);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.SNMP_MODIFY);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11272 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ CommandExecuter thread = new CommandExecuter(session);
+
+ ExecuteMode mode;
+ String redirectPage;
+
+ String button_mode = request.getParameter("button");
+ // button mode : null
+ if (button_mode == null) {
+ MessageView error = new MessageView(41063, LogCategorySet.GUI_SNMP,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11273 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ // button mode : save
+ else if (button_mode.equals(ButtonMode.SAVE)) {
+ mode = ExecuteMode.SNMP_INFO_SAVE;
+ redirectPage = RedirectPages.SNMP_MODIFY_EXECUTIVE;
+ }
+ // button mode : save and sync
+ else if (button_mode.equals(ButtonMode.SAVESYNC)) {
+ mode = ExecuteMode.SNMP_INFO_SAVESYNC;
+ redirectPage = RedirectPages.SAVE_SYNC_EXECUTIVE;
+
+ SessionTransData trans = new SessionTransData();
+ trans.sourceURI = RedirectPages.SNMP_MODIFY;
+ trans.destURI = RedirectPages.SNMP_MODIFY;
+ trans.errorURI = RedirectPages.SNMP_MODIFY_NG;
+ session.setAttribute(SessionKeys.PAGE_TRANSDATA, trans);
+ } else {
+ MessageView error = new MessageView(41064, LogCategorySet.GUI_SNMP,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11274 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ try {
+ thread.setExecute(mode, snmp);
+ thread.start();
+ } catch (Exception e) {
+ MessageView error = new MessageView(41065, LogCategorySet.GUI_SNMP,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11275 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ response.sendRedirect(redirectPage);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11276 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /**
+ *
+ * <p>
+ * validationCheck method
+ * </p>
+ *
+ * @param session
+ * @param str_snmpInterval
+ * @param snmp
+ * @return
+ */
+
+ private boolean validationcheck(HttpSession session,
+ String str_SnmpInterval, SnmpAgentData snmp) {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("SnmpAgentServlet::validationCheck(HttpSession session, String str_SnmpInterval, SnmpAgentData snmp) in ");
+ buf.append("session=(" + session + "), ");
+ buf.append("str_SnmpInterval=(" + str_SnmpInterval + "), ");
+ buf.append("snmp=(" + snmp + ")");
+ logger.debug("11277 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ boolean validationFlag = true;
+
+ int MIN_SNMP_INTERVAL = 1;
+ int MAX_SNMP_INTERVAL = 999;
+ int int_SnmpInterval = 1;
+
+ if (str_SnmpInterval.length() == 0) {
+ session.setAttribute(SessionKeys.INVALID_MESSAGE,
+ Message.REQUIED_ITEM);
+ validationFlag = false;
+ } else {
+ try {
+ int_SnmpInterval = Integer.parseInt(str_SnmpInterval);
+ if ((int_SnmpInterval < MIN_SNMP_INTERVAL)
+ || (int_SnmpInterval > MAX_SNMP_INTERVAL)) {
+ session.setAttribute(SessionKeys.INVALID_MESSAGE,
+ Message.VALIDATION_ERROR);
+ validationFlag = false;
+ }
+ } catch (NumberFormatException e) {
+ session.setAttribute(SessionKeys.INVALID_MESSAGE,
+ Message.VALIDATION_ERROR);
+ validationFlag = false;
+ }
+ }
+ snmp.interval = int_SnmpInterval;
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11278 SnmpAgentServlet::validationCheck(HttpSession session, String str_SnmpInterval, SnmpAgentData snmp) out return=" + validationFlag);
+ }
+ // --- debug log (out method) ---
+ return validationFlag;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.*;
+
+
+/**
+ *
+ * <p>class SoRunServlet</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * <p>Servlet implementation class for Servlet: SoRun</p>
+ * @author kubota
+ */
+public class SoRunServlet extends L7guiServletBase {
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public SoRunServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11311 class SoRunServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("SoRunServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11312 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11313 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11314 SoRunServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("SoRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11315 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11316 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ // check login session
+ super.doPost(request, response);
+
+ HttpSession session = request.getSession(false);
+ if (login == false || session == null) {
+ if (session != null) {
+ MessageView error = new MessageView(41077, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ }
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11317 SoRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ request.setCharacterEncoding("UTF-8");
+ String buttonMode = request.getParameter("button");
+ if ((buttonMode != null) && (buttonMode.equals(ButtonMode.SWITCH_OVER))) {
+ CommandExecuter thread = new CommandExecuter(session);
+ try {
+ thread.setExecute(ExecuteMode.CLUSTER_SWITCHORVER);
+ thread.start();
+ }
+ catch(Exception e) {
+ MessageView error = new MessageView(41078, LogCategorySet.GUI_REDUNDANT, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11318 SoRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ }
+ else {
+ MessageView error = new MessageView(41079, LogCategorySet.GUI_REDUNDANT, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11319 SoRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ response.sendRedirect(RedirectPages.SO_EXECUTIVE);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11320 SoRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.HashSet;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.ExecuteMode;
+import org.ultramonkey.l7.model.LogCategorySet;
+import org.ultramonkey.l7.model.Message;
+import org.ultramonkey.l7.model.MessageView;
+import org.ultramonkey.l7.model.SyncCategoryIdSet;
+
+/**
+ *
+ * <p>
+ * class SaveStateServlet
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author kubota
+ */
+public class SyncStateServlet extends org.ultramonkey.l7.view.L7guiServletBase {
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public SyncStateServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11431 class SyncStateServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("SyncStateServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11432 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11433 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11434 SyncStateServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("SyncStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11435 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11436 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ // check login session
+ super.doPost(request, response);
+
+ HttpSession session = request.getSession(false);
+ if (login == false || session == null) {
+ if (session != null) {
+ MessageView error = new MessageView(41191, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ }
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11437 SyncStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ // get checkbox Category Data & button Mode
+ request.setCharacterEncoding("UTF-8");
+ String selectCheck[] = request.getParameterValues("sync_category");
+ String button_mode = request.getParameter("button");
+ if (button_mode == null || button_mode.equals(ButtonMode.SAVESYNC) == false) {
+ MessageView error = new MessageView(41192, LogCategorySet.GUI_SYNC, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11438 SyncStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ if (selectCheck == null) {
+ MessageView error = new MessageView(21084, LogCategorySet.GUI_SYNC,
+ Message.SYNC_CATEGORY_SELECT_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.SYNC);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11439 SyncStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ HashSet<Integer> syncCategory = new HashSet<Integer>();
+
+ for (int i = 0; i < selectCheck.length; i++) {
+ try {
+ int categoryNum = SyncCategoryIdSet
+ .toCategoryId(selectCheck[i]);
+ syncCategory.add(categoryNum);
+ } catch (MessageView mem) {
+ MessageView error = new MessageView(21085, LogCategorySet.GUI_SYNC,
+ Message.SYNC_CATEGORY_SELECT_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.SYNC);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11440 SyncStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ }
+
+ CommandExecuter thread = new CommandExecuter(session);
+
+ try {
+ thread.setExecute(ExecuteMode.SYNC, syncCategory);
+ thread.start();
+ } catch (Exception e) {
+ MessageView error = new MessageView(41193, LogCategorySet.GUI_SYNC, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11441 SyncStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ response.sendRedirect(RedirectPages.SYNC_EXECUTIVE);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11442 SyncStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.*;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.FileNotWriteException;
+import org.ultramonkey.l7.model.LogCategorySet;
+import org.ultramonkey.l7.model.Message;
+import org.ultramonkey.l7.model.MessageView;
+import org.ultramonkey.l7.model.UserData;
+import org.ultramonkey.l7.model.UserManager;
+
+/**
+ *
+ * <p>
+ * class UserAddServlet
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author kubota
+ */
+public class UserAddServlet extends org.ultramonkey.l7.view.L7guiServletBase {
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public UserAddServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11321 class UserAddServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("UserAddServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11322 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11323 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11324 UserAddServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("UserAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11325 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11326 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ // check login session
+ super.doPost(request, response);
+
+ HttpSession session = request.getSession(false);
+ if (login == false || session == null) {
+ if (session != null) {
+ MessageView error = new MessageView(41080, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ }
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11327 UserAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ request.setCharacterEncoding("UTF-8");
+ String userId = request.getParameter("userId");
+ String description = request.getParameter("description");
+ String newPass1 = request.getParameter("new1_passwd");
+ String newPass2 = request.getParameter("new2_passwd");
+ String button_mode = request.getParameter("button");
+
+ if ((userId == null) || (description == null) || (newPass1 == null)
+ || (newPass2 == null) || (button_mode == null)
+ || (button_mode.equals(ButtonMode.ADD) == false)) {
+ MessageView error = new MessageView(41081, LogCategorySet.GUI_USER_MANAGE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11328 UserAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ boolean validationFlag = true;
+ validationFlag = validationCheck(session, userId, description,
+ newPass1, newPass2);
+ if (validationFlag == false) {
+ UserData inputUser = new UserData();
+ inputUser.userName = userId;
+ inputUser.description = description;
+ session.setAttribute(SessionKeys.INPUT_USERDATA, inputUser);
+ response.sendRedirect(RedirectPages.USER_ADD);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11329 UserAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ UserManager user = UserManager.getInstance();
+
+ Vector<UserData> userList;
+ boolean addUser = false;
+ try {
+ userList = user.getUserList();
+ int userCount = userList.size();
+ if (userCount >= 16){
+ MessageView error = new MessageView(41082, LogCategorySet.GUI_IO_FILE,
+ Message.USER_MAX);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.USER_ADD_FAIL);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11330 UserAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ addUser = user.addUser(userId, newPass1, 0, description);
+ }
+ catch (FileNotWriteException e) {
+ MessageView error = new MessageView(41083, LogCategorySet.GUI_IO_FILE, Message.WRITE_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11331 UserAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ catch(Exception e){
+ MessageView error = new MessageView(41084, LogCategorySet.GUI_START_STOP,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11332 UserAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ if (addUser == true) {
+ MessageView message = new MessageView(21041, LogCategorySet.GUI_USER_MANAGE,
+ Message.USER_ADD_SUCCESS);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, message);
+ session.setAttribute(SessionKeys.GUI_SYNC_STATE, SessionKeys.NO_SYNC);
+ response.sendRedirect(RedirectPages.USER_MANAGE);
+ } else {
+ MessageView error = new MessageView(41085, LogCategorySet.GUI_USER_MANAGE,
+ Message.SAME_USER_EXISTS);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.USER_ADD_FAIL);
+ }
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11333 UserAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /**
+ *
+ * <p>
+ * validationCheck method
+ * </p>
+ *
+ * @param session
+ * @param userId
+ * @param description
+ * @param curPass
+ * @param newPass1
+ * @param newPass2
+ * @return
+ */
+ protected boolean validationCheck(HttpSession session, String userId,
+ String description, String newPass1, String newPass2) {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("UserAddServlet::validationCheck(HttpSession session, String userId, String description, String newPass1, String newPass2) in ");
+ buf.append("session=(" + session + "), ");
+ buf.append("userId=\"" + userId + "\", ");
+ buf.append("description=\"" + description + "\", ");
+ buf.append("newPass1=\"" + newPass1 + "\", ");
+ buf.append("newPass2=\"" + newPass2);
+ logger.debug("11334 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ boolean validationFlag = true;
+ final int MAX_USER_LENGTH = 16;
+ final int MAX_DESCRIPTION_LENGTH = 64;
+ final int MIN_PASS_LENGTH = 6;
+ final int MAX_PASS_LENGTH = 16;
+
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+
+ if (session == null) {
+ validationFlag = false;
+ } else if (userId == null || description == null || newPass1 == null || newPass2 == null) {
+ MessageView error = new MessageView(21042, LogCategorySet.GUI_USER_MANAGE, Message.INVALID_VALUE);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ validationFlag = false;
+ } else if ((userId.length() == 0) && (description.length() == 0)
+ && (newPass1.length() == 0) && (newPass2.length() == 0)) {
+ MessageView error = new MessageView(21043, LogCategorySet.GUI_USER_MANAGE, Message.NOT_EXIST);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ validationFlag = false;
+ } else if ((userId.length() == 0) || (newPass1.length() == 0)
+ || (newPass2.length() == 0)) {
+ MessageView error = new MessageView(21044, LogCategorySet.GUI_USER_MANAGE,
+ Message.NOT_INPUT_ITEM);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ validationFlag = false;
+ }
+ else {
+ Matcher matcherUserId = pattern.matcher(userId);
+ Matcher matcherNewPass1 = pattern.matcher(newPass1);
+ Matcher matcherNewPass2 = pattern.matcher(newPass2);
+ Matcher matcherDescription = pattern.matcher(description);
+
+ if (matcherUserId.find() || matcherNewPass1.find()
+ || matcherNewPass2.find() || matcherDescription.find()) {
+ MessageView error = new MessageView(21045, LogCategorySet.GUI_USER_MANAGE,
+ "Input item : " + Message.INVALID_VALUE);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ validationFlag = false;
+ } else if (false == newPass1.equals(newPass2)) {
+ MessageView error = new MessageView(21046, LogCategorySet.GUI_USER_MANAGE,
+ Message.NOT_EQUAL);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ validationFlag = false;
+ } else if ((userId.length() > MAX_USER_LENGTH)
+ || (newPass1.length() < MIN_PASS_LENGTH)
+ || (newPass1.length() > MAX_PASS_LENGTH)
+ || (description.length() > MAX_DESCRIPTION_LENGTH)) {
+ MessageView error = new MessageView(21047, LogCategorySet.GUI_USER_MANAGE,
+ Message.INVALID_VALUE);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ validationFlag = false;
+ }
+ }
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11335 UserAddServlet::validationCheck(HttpSession session, String userId, String description, String newPass1, String newPass2) out return=" + validationFlag);
+ }
+ // --- debug log (out method) ---
+ return validationFlag;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.*;
+
+/**
+ *
+ * <p>
+ * class PwChangeServlet
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author kubota
+ */
+
+public class UserModServlet extends org.ultramonkey.l7.view.L7guiServletBase {
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public UserModServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11414 class UserModServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("UserModServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11415 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11416 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11417 UserModServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11418 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11419 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ // check login session
+ super.doPost(request, response);
+
+ HttpSession session = request.getSession(false);
+ if (login == false || session == null) {
+ if (session != null) {
+ MessageView error = new MessageView(41184, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ }
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11420 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ UserData currentUser = (UserData) session
+ .getAttribute(SessionKeys.LOGIN_SESSION);
+ if (currentUser == null) {
+ MessageView error = new MessageView(41185, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11421 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ // post Data check
+ request.setCharacterEncoding("UTF-8");
+ String description = request.getParameter("description");
+ String curPass = request.getParameter("password");
+ String newPass1 = request.getParameter("new1_passwd");
+ String newPass2 = request.getParameter("new2_passwd");
+ String button_mode = request.getParameter("button");
+ if ((description == null) || (curPass == null) || (newPass1 == null)
+ || (newPass2 == null) || (button_mode == null)
+ || (button_mode.equals(ButtonMode.CHANGE) == false)) {
+ MessageView error = new MessageView(41186, LogCategorySet.GUI_USER_MANAGE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11422 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ boolean validationFlag = true;
+ validationFlag = validationCheck(session, description, curPass,
+ newPass1, newPass2);
+ if (validationFlag == false) {
+ UserData inputUser = new UserData();
+ inputUser.description = description;
+ session.setAttribute(SessionKeys.INPUT_USERDATA, inputUser);
+ response.sendRedirect(RedirectPages.USER_MODIFY);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11423 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ // User authentication
+ UserManager user = UserManager.getInstance();
+ UserData authCheck = null;
+ try {
+ authCheck = user.authUser(currentUser.userName, curPass);
+ } catch (Exception e) {
+ MessageView error = new MessageView(41187, LogCategorySet.GUI_START_STOP,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11424 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ if (authCheck == null) {
+ MessageView error = new MessageView(21076, LogCategorySet.GUI_USER_MANAGE,
+ Message.PASSWORD_INVALID);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.USER_MODIFY);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11425 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ // Password Change
+ UserData modUser = new UserData();
+ modUser.userName = currentUser.userName;
+ modUser.description = description;
+ modUser.passwd = newPass1;
+
+ boolean passChange = true;
+ try {
+ passChange = user.changeUser(modUser);
+ } catch (FileNotWriteException e) {
+ MessageView error = new MessageView(41188,LogCategorySet.GUI_IO_FILE,
+ Message.WRITE_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11426 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ } catch (Exception e) {
+ MessageView error = new MessageView(41189, LogCategorySet.GUI_USER_MANAGE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11427 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ if (passChange == true) {
+ session.setAttribute(SessionKeys.LOGIN_SESSION, modUser);
+ MessageView error = new MessageView(21077, LogCategorySet.GUI_USER_MANAGE,
+ Message.USER_CHANGE_SUCCESS);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ session.setAttribute(SessionKeys.GUI_SYNC_STATE, SessionKeys.NO_SYNC);
+ response.sendRedirect(RedirectPages.USER_MODIFY_SUCCESS);
+ } else {
+ session.setAttribute(SessionKeys.LOGIN_SESSION, authCheck);
+ MessageView error = new MessageView(41190, LogCategorySet.GUI_USER_MANAGE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.USER_MODIFY_FAIL);
+ }
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11428 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /**
+ *
+ * <p>
+ * validationCheck method
+ * </p>
+ *
+ * @param session
+ * @param description
+ * @param curPass
+ * @param newPass1
+ * @param newPass2
+ * @return
+ */
+ boolean validationCheck(HttpSession session, String description,
+ String curPass, String newPass1, String newPass2) {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("UserModServlet::validationCheck(HttpSession session, String description, String newPass1, String newPass2) in ");
+ buf.append("session=(" + session + "), ");
+ buf.append("description=\"" + description + "\", ");
+ buf.append("newPass1=\"" + newPass1 + "\", ");
+ buf.append("newPass2=\"" + newPass2);
+ logger.debug("11429 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ boolean validationFlag = true;
+ final int MAX_DESCRIPTION_LENGTH = 64;
+ final int MIN_PASS_LENGTH = 6;
+ final int MAX_PASS_LENGTH = 16;
+
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+
+ if ((description.length() == 0) && (curPass.length() == 0)
+ && (newPass1.length() == 0) && (newPass2.length() == 0)) {
+ MessageView error = new MessageView(21078, LogCategorySet.GUI_USER_MANAGE,
+ Message.NOT_EXIST);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ validationFlag = false;
+ }
+
+ else if (description.length() != 0) {
+ Matcher matcher = pattern.matcher(description);
+ if ((description.length() > MAX_DESCRIPTION_LENGTH) || matcher.find() ){
+ MessageView error = new MessageView(21079, LogCategorySet.GUI_USER_MANAGE,
+ "Description : " + Message.INVALID_VALUE);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ validationFlag = false;
+ }
+ }
+
+ if ( (curPass.length() == 0 ) || (newPass1.length() == 0) || (newPass2.length() == 0) ){
+ MessageView error = new MessageView(21080, LogCategorySet.GUI_USER_MANAGE,
+ "Password : " + Message.REQUIED_ITEM);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ validationFlag = false;
+ } else {
+ Matcher matcherCurPass = pattern.matcher(curPass);
+ Matcher matcherNewPass1 = pattern.matcher(newPass1);
+ Matcher matcherNewPass2 = pattern.matcher(newPass2);
+
+ if (matcherCurPass.find() || matcherNewPass1.find()
+ || matcherNewPass2.find()) {
+ MessageView error = new MessageView(21081, LogCategorySet.GUI_USER_MANAGE,
+ "Input item : "+ Message.INVALID_VALUE);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ validationFlag = false;
+ } else if (false == newPass1.equals(newPass2)) {
+ MessageView error = new MessageView(21082, LogCategorySet.GUI_USER_MANAGE,
+ Message.NOT_EQUAL);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ validationFlag = false;
+ }
+ else if ((newPass1.length() < MIN_PASS_LENGTH) || (newPass1.length() > MAX_PASS_LENGTH)){
+ MessageView error = new MessageView(21083, LogCategorySet.GUI_USER_MANAGE,
+ Message.INVALID_VALUE);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ validationFlag = false;
+ }
+ }
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11430 UserModServlet::validationCheck(HttpSession session, String description, String newPass1, String newPass2) out return=" + validationFlag);
+ }
+ // --- debug log (out method) ---
+ return validationFlag;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.FileNotWriteException;
+import org.ultramonkey.l7.model.LogCategorySet;
+import org.ultramonkey.l7.model.Message;
+import org.ultramonkey.l7.model.MessageView;
+import org.ultramonkey.l7.model.UserData;
+import org.ultramonkey.l7.model.UserManager;
+
+/**
+ *
+ * <p>
+ * class UserRemoveServlet
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author kubota
+ */
+public class UserRemoveServlet extends org.ultramonkey.l7.view.L7guiServletBase {
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public UserRemoveServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11443 class UserModServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("UserModServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11444 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11445 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11446 UserModServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
+ * HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11447 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11448 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ // check login session
+ super.doPost(request, response);
+
+ HttpSession session = request.getSession(false);
+ if (login == false || session == null) {
+ if (session != null) {
+ MessageView error = new MessageView(41194, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ }
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11449 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ UserData currentUser = (UserData) session
+ .getAttribute(SessionKeys.LOGIN_SESSION);
+ if (currentUser == null) {
+ MessageView error = new MessageView(41195, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11450 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ // get checkbox UserName Data & button Mode
+ request.setCharacterEncoding("UTF-8");
+ String selectCheck[] = request.getParameterValues("ck_user");
+ String button_mode = request.getParameter("button");
+ if (button_mode == null
+ || button_mode.equals(ButtonMode.DELETE) == false) {
+ MessageView error = new MessageView(41196, LogCategorySet.GUI_USER_MANAGE, Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11451 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ if (selectCheck == null) {
+ MessageView error = new MessageView(21086, LogCategorySet.GUI_USER_MANAGE,
+ Message.USER_REMOVE_SELECT_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.USER_MANAGE);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11452 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ UserManager user = UserManager.getInstance();
+ boolean removeUser = true;
+ boolean removeFlag = true;
+ String successRemoveUser = "";
+ String failRemoveUser = "";
+ for (int i = 0; i < selectCheck.length; i++) {
+ if (true == selectCheck[i].equals(currentUser.userName)) {
+ MessageView error = new MessageView(21087, LogCategorySet.GUI_USER_MANAGE,
+ Message.SELF_USER_DELETE);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.USER_MANAGE);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11453 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ }
+
+ for (int i = 0; i < selectCheck.length; i++) {
+ try {
+ removeUser = user.delUser(selectCheck[i]);
+ } catch (FileNotWriteException e) {
+ MessageView error = new MessageView(41197, LogCategorySet.GUI_IO_FILE,
+ Message.WRITE_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11454 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ } catch (Exception e) {
+ MessageView error = new MessageView(41198, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11455 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ if (true == removeUser) {
+ successRemoveUser += selectCheck[i] + " ";
+ } else {
+ removeFlag = false;
+ failRemoveUser += selectCheck[i] + " ";
+ }
+ }
+
+ if (removeFlag == true) {
+ MessageView message = new MessageView(21088, LogCategorySet.GUI_USER_MANAGE,
+ "UserName : " + successRemoveUser + Message.USER_DELETE_SUCCESS);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, message);
+ session.setAttribute(SessionKeys.GUI_SYNC_STATE, SessionKeys.NO_SYNC);
+ response.sendRedirect(RedirectPages.USER_MANAGE);
+ } else {
+ if (successRemoveUser.length() != 0) {
+ MessageView error = new MessageView(21089, LogCategorySet.GUI_USER_MANAGE,
+ "UserName : " + successRemoveUser + Message.USER_DELETE_SUCCESS
+ + "<br />\n" + "UserName : " + failRemoveUser
+ + Message.USER_DELETE_FAIL);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ } else {
+ MessageView message = new MessageView(41199, LogCategorySet.GUI_USER_MANAGE,
+ "UserName : " + failRemoveUser + Message.USER_DELETE_FAIL);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, message);
+ }
+ response.sendRedirect(RedirectPages.USER_DELETE_FAIL);
+ }
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11456 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.*;
+import org.ultramonkey.l7.controller.*;
+
+
+ /**
+ * <p>class VSAddServlet</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author kubota
+ */
+public class VSAddServlet extends org.ultramonkey.l7.view.L7guiServletBase {
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public VSAddServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11376 class VSAddServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("VSAddServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11377 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11378 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11379 VSAddServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("VSAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11380 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11381 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ // check login session
+ super.doPost(request, response);
+
+ HttpSession session = request.getSession(false);
+ if (login == false || session == null) {
+ if (session != null) {
+ MessageView error = new MessageView(41169, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ }
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11382 VSAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ request.setCharacterEncoding("UTF-8");
+ HashMap<String, String[]> tmpMap = (HashMap<String, String[]>) request.getParameterMap();
+ if (tmpMap == null){
+ MessageView error = new MessageView(41170, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11383 VSAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ HashMap<String, String> inputVsMap = new HashMap<String, String>();
+ ArrayList<Integer> realRemoveKey = new ArrayList<Integer>();
+ if (tmpMap != null) {
+ Iterator i = tmpMap.keySet().iterator();
+ while (i.hasNext()) {
+ String key = (String) i.next();
+
+ Pattern p = Pattern.compile("rs(\\d+)_remove");
+ Matcher m = p.matcher(key);
+ if (m.matches())
+ realRemoveKey.add(Integer.parseInt(m.group(1)));
+
+ inputVsMap.put(key, tmpMap.get(key)[0]);
+ }
+
+ if (inputVsMap.containsKey(ButtonMode.REMOVE) && realRemoveKey.size() > 0) {
+ for (int key : realRemoveKey) {
+ try {
+ inputVsMap.remove("rs" + key + "_ip");
+ inputVsMap.remove("rs" + key + "_port");
+ inputVsMap.remove("rs" + key + "_weight");
+ } catch (Exception e) { }
+ }
+ }
+ }
+ HashMap<String, String> invalidMap = new HashMap<String, String>();
+
+ boolean validationFlag = true;
+ VirtualSetting vs = new VirtualSetting();
+
+ // validation check
+ ValidationCheck val = new ValidationCheck();
+ validationFlag = val.vsCheck(inputVsMap, invalidMap, vs);
+
+ if (inputVsMap.containsKey(ButtonMode.ADD)) {
+ String new_ip = inputVsMap.get("new_ip");
+ String new_port = inputVsMap.get("new_port");
+ String new_weight = inputVsMap.get("new_weight");
+
+ if (new_ip != null && new_port != null && new_weight != null &&
+ new_ip.length() != 0 && new_ip.length() != 0 && new_weight.length() != 0) {
+ try {
+ EndPoint new_real = new EndPoint(new_ip, new_port, Integer.parseInt(new_weight), 0, 0);
+ for (EndPoint real : vs.real) {
+ if (real.equals(new_real)) {
+ new_real = null;
+ MessageView error = new MessageView(41171, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.REAL_SERVER_EXIST);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ break;
+ }
+ }
+ if (new_real != null)
+ vs.real.add(new_real);
+ } catch (Exception e) { }
+ }
+ }
+
+ if (inputVsMap.containsKey(ButtonMode.REMOVE) || inputVsMap.containsKey(ButtonMode.ADD)) {
+ session.setAttribute(SessionKeys.INPUT_VS, vs);
+ response.sendRedirect(RedirectPages.VS_ADD);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11384 VSAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ if (validationFlag == false) {
+ MessageView error = new MessageView(21074, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.VALIDATION_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ session.setAttribute(SessionKeys.INPUT_VS, vs);
+ session.setAttribute(SessionKeys.INVALID_MESSAGE, invalidMap);
+
+ response.sendRedirect(RedirectPages.VS_ADD);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11385 VSAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ String vip = inputVsMap.get("vip");
+ String port = inputVsMap.get("port");
+ String protomod = inputVsMap.get("protomod");
+ String option = inputVsMap.get("option");
+ String vsName = "";
+
+ if ( (vip != null) && (port != null) && (protomod != null) && (option != null)){
+ vsName = vip + ":" + port + " " + protomod + " " + option;
+ session.setAttribute(SessionKeys.VS_NAME, vsName);
+ }
+
+ CommandExecuter thread = new CommandExecuter(session);
+
+ ExecuteMode mode = ExecuteMode.NONE;
+ String redirectPage = "";
+
+ String button_mode = inputVsMap.get("button");
+ // button mode : apply
+ if (button_mode != null && button_mode.equals(ButtonMode.APPLY)) {
+ mode = ExecuteMode.VS_ADD_APPLY;
+ redirectPage = RedirectPages.VS_ADD_EXECUTIVE;
+ }
+ // button mode : save
+ else if (button_mode != null && button_mode.equals(ButtonMode.SAVE)) {
+ mode = ExecuteMode.VS_ADD_SAVE;
+ redirectPage = RedirectPages.VS_ADD_EXECUTIVE;
+ }
+ // button mode : save and sync
+ else if (button_mode != null && button_mode.equals(ButtonMode.SAVESYNC)) {
+ mode = ExecuteMode.VS_ADD_SAVESYNC;
+ redirectPage = RedirectPages.SAVE_SYNC_EXECUTIVE;
+
+ SessionTransData trans = new SessionTransData();
+ trans.sourceURI = RedirectPages.VS_ADD;
+ trans.destURI = RedirectPages.STATE_INFO;
+ trans.errorURI = RedirectPages.VS_ADD_NG;
+ session.setAttribute(SessionKeys.PAGE_TRANSDATA, trans);
+ }
+ else {
+ MessageView error = new MessageView(41172, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11386 VSAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ try {
+ thread.setExecute(mode, vs);
+ thread.start();
+ }
+ catch(Exception e) {
+ MessageView error = new MessageView(41173, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11387 VSAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ response.sendRedirect(redirectPage);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11388 VSAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.model.*;
+import org.ultramonkey.l7.controller.*;
+
+/**
+ * <p>class VSModServlet</p>
+ * <p>Copyright(c) NTT COMWARE 2008</p>
+ * @author kubota
+ */
+public class VSModServlet extends L7guiServletBase {
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public VSModServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11349 class VSModServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("VSModServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11350 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11351 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11352 VSModServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11353 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11354 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ // check login session
+ super.doPost(request, response);
+
+ HttpSession session = request.getSession(false);
+ if (login == false || session == null) {
+ if (session != null) {
+ MessageView error = new MessageView(41087, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ }
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11355 VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ request.setCharacterEncoding("UTF-8");
+ HashMap<String, String[]> tmpMap = (HashMap<String, String[]>) request.getParameterMap();
+ if (tmpMap == null){
+ MessageView error = new MessageView(41088, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11356 VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ HashMap<String, String> inputVsMap = new HashMap<String, String>();
+ ArrayList<Integer> realRemoveKey = new ArrayList<Integer>();
+
+ Iterator i = tmpMap.keySet().iterator();
+ while (i.hasNext()) {
+ String key = (String) i.next();
+
+ Pattern p = Pattern.compile("rs(\\d+)_remove");
+ Matcher m = p.matcher(key);
+ if (m.matches())
+ realRemoveKey.add(Integer.parseInt(m.group(1)));
+
+ inputVsMap.put(key, tmpMap.get(key)[0]);
+ }
+
+ if (inputVsMap.containsKey(ButtonMode.REMOVE) && realRemoveKey.size() > 0) {
+ for (int key : realRemoveKey) {
+ try {
+ inputVsMap.remove("rs" + key + "_ip");
+ inputVsMap.remove("rs" + key + "_port");
+ inputVsMap.remove("rs" + key + "_weight");
+ } catch (Exception e) { }
+ }
+ }
+
+ HashMap<String, String> invalidMap = new HashMap<String, String>();
+
+ boolean validationFlag = true;
+ VirtualSetting vs = new VirtualSetting();
+
+ // validation check
+ ValidationCheck val = new ValidationCheck();
+ validationFlag = val.vsCheck(inputVsMap, invalidMap, vs);
+
+ if (inputVsMap.containsKey(ButtonMode.ADD)) {
+ String new_ip = inputVsMap.get("new_ip");
+ String new_port = inputVsMap.get("new_port");
+ String new_weight = inputVsMap.get("new_weight");
+
+ if (new_ip != null && new_port != null && new_weight != null &&
+ new_ip.length() != 0 && new_ip.length() != 0 && new_weight.length() != 0) {
+ try {
+ EndPoint new_real = new EndPoint(new_ip, new_port, Integer.parseInt(new_weight), 0, 0);
+ for (EndPoint real : vs.real) {
+ if (real.equals(new_real)) {
+ new_real = null;
+ MessageView error = new MessageView(41089, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.REAL_SERVER_EXIST);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ break;
+ }
+ }
+ if (new_real != null)
+ vs.real.add(new_real);
+ } catch (Exception e) { }
+ }
+ }
+
+ if (inputVsMap.containsKey(ButtonMode.REMOVE) || inputVsMap.containsKey(ButtonMode.ADD)) {
+ session.setAttribute(SessionKeys.INPUT_VS, vs);
+ response.sendRedirect(RedirectPages.VS_MODIFY);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11357 VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ if (validationFlag == false) {
+ MessageView error = new MessageView(21048, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.VALIDATION_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ session.setAttribute(SessionKeys.INPUT_VS, vs);
+ session.setAttribute(SessionKeys.INVALID_MESSAGE, invalidMap);
+
+ response.sendRedirect(RedirectPages.VS_MODIFY);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11358 VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ VirtualSetting oldVs = (VirtualSetting) session.getAttribute(SessionKeys.OLD_VS);
+ if (oldVs == null) {
+ MessageView error = new MessageView(41090, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11359 VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ String vsName = oldVs.virtual.host + ":" + oldVs.virtual.port + " " +
+ oldVs.protomod + " " + oldVs.option;
+ session.setAttribute(SessionKeys.VS_NAME, vsName);
+
+ CommandExecuter thread = new CommandExecuter(session);
+
+ ExecuteMode mode;
+ String redirectPage;
+
+ String button_mode = inputVsMap.get("button");
+ // button mode : apply
+ if (button_mode != null && button_mode.equals(ButtonMode.APPLY)) {
+ mode = ExecuteMode.VS_MODIFY_APPLY;
+ redirectPage = RedirectPages.VS_MODIFY_EXECUTIVE;
+ }
+ // button mode : save
+ else if (button_mode != null && button_mode.equals(ButtonMode.SAVE)) {
+ mode = ExecuteMode.VS_MODIFY_SAVE;
+ redirectPage = RedirectPages.VS_MODIFY_EXECUTIVE;
+ }
+ // button mode : save and sync
+ else if (button_mode != null && button_mode.equals(ButtonMode.SAVESYNC)) {
+ mode = ExecuteMode.VS_MODIFY_SAVESYNC;
+ redirectPage = RedirectPages.SAVE_SYNC_EXECUTIVE;
+
+ SessionTransData trans = new SessionTransData();
+ trans.sourceURI = RedirectPages.VS_MODIFY;
+ trans.destURI = RedirectPages.STATE_INFO;
+ trans.errorURI = RedirectPages.VS_MODIFY_NG;
+ session.setAttribute(SessionKeys.PAGE_TRANSDATA, trans);
+ }
+ else {
+ MessageView error = new MessageView(41091, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11360 VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ try {
+ thread.setExecute(mode, oldVs, vs);
+ thread.start();
+ }
+ catch(Exception e)
+ {
+ MessageView error = new MessageView(41092, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11361 VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ response.sendRedirect(redirectPage);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11362 VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.controller.L7vsAdmData;
+import org.ultramonkey.l7.controller.VirtualSetting;
+import org.ultramonkey.l7.model.ExecuteMode;
+import org.ultramonkey.l7.model.L7guiFramework;
+import org.ultramonkey.l7.model.LogCategorySet;
+import org.ultramonkey.l7.model.Message;
+import org.ultramonkey.l7.model.MessageView;
+import org.ultramonkey.l7.model.SessionTransData;
+
+/**
+ * Servlet implementation class for Servlet: VSRemoveServlet
+ */
+ public class VSRemoveServlet extends org.ultramonkey.l7.view.L7guiServletBase{
+ static final long serialVersionUID = 1L;
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#HttpServlet()
+ */
+ public VSRemoveServlet() {
+ super();
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11400 class VSRemoveServlet created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("VSRemoveServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11401 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ logger.debug("11402 QueryString=\"" + request.getQueryString() + "\"");
+ }
+ // --- debug log (in method) ---
+
+ response.sendRedirect(RedirectPages.LOGIN);
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11403 VSRemoveServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+
+ /* (non-Java-doc)
+ * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in ");
+ buf.append("request=(" + request + "), ");
+ buf.append("response=(" + response + ")");
+ logger.debug("11404 " + buf.toString());
+ request.setCharacterEncoding("UTF-8");
+ Enumeration keys = request.getParameterNames();
+ String post = "";
+ while (keys.hasMoreElements()) {
+ if (post.length() != 0)
+ post += "&";
+ String key = (String) keys.nextElement();
+ post += key + "=" + request.getParameter(key);
+ }
+ logger.debug("11405 PostData=\"" + post + "\"");
+ }
+ // --- debug log (in method) ---
+
+ // check login session
+ super.doPost(request, response);
+
+ HttpSession session = request.getSession(false);
+ if (login == false || session == null) {
+ if (session != null) {
+ MessageView error = new MessageView(41178, LogCategorySet.GUI_USER_AUTHENTICATION,
+ Message.INVALID_SESSSION);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ }
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11406 VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ /*
+ * get post data
+ */
+ request.setCharacterEncoding("UTF-8");
+ String post = request.getParameter("vs"); // ex. "10.10.10.10:80:cinsert:--cookie-name monkey"
+ if (post == null) {
+ MessageView error = new MessageView(21075, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.VS_SELECT_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.STATE_INFO);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11407 VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ String params[] = post.split(":", 4);
+ if (params == null || params.length != 4) {
+ MessageView error = new MessageView(41179, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11408 VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ String vsName = params[0] + ":" + params[1] + " " + params[2] + " " + params[3];
+ session.setAttribute(SessionKeys.VS_NAME, vsName);
+
+
+ L7guiFramework framework = new L7guiFramework();
+ L7vsAdmData admDataList = framework.getAdmData();
+ if (admDataList == null){
+ MessageView error = new MessageView(41180, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11409 VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ VirtualSetting vs = null;
+ /*
+ * get l7vsadm data from L7guiFramework
+ * & compare add l7vsadm data with post data
+ */
+ for (int i = 0; i < admDataList.virtualSettings.size(); i++) {
+ VirtualSetting v = (VirtualSetting) admDataList.virtualSettings.elementAt(i);
+ if (v.virtual.host.equals(params[0]) && v.virtual.port.equals(params[1]) &&
+ v.protomod.equals(params[2]) && v.option.equals(params[3])) {
+ vs = v;
+ break;
+ }
+ }
+
+ /*
+ * error. no such VirtualService
+ */
+ if (vs == null) {
+ MessageView error = new MessageView(41181, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.NO_VS);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.VS_REMOVE_NG);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11410 VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+
+ CommandExecuter thread = new CommandExecuter(session);
+
+ ExecuteMode mode;
+ String redirectPage;
+
+
+ String button_mode = request.getParameter("button_remove");
+
+ // button mode : apply
+ if (button_mode != null && button_mode.equals(ButtonMode.APPLY)) {
+ mode = ExecuteMode.VS_REMOVE_APPLY;
+ redirectPage = RedirectPages.VS_REMOVE_EXECUTIVE;
+ }
+ // button mode : save
+ else if (button_mode != null && button_mode.equals(ButtonMode.SAVE)) {
+ mode = ExecuteMode.VS_REMOVE_SAVE;
+ redirectPage = RedirectPages.VS_REMOVE_EXECUTIVE;
+ }
+ // button mode : save and sync
+ else if (button_mode != null && button_mode.equals(ButtonMode.SAVESYNC)) {
+ mode = ExecuteMode.VS_REMOVE_SAVESYNC;
+ redirectPage = RedirectPages.SAVE_SYNC_EXECUTIVE;
+
+ SessionTransData trans = new SessionTransData();
+ trans.sourceURI = RedirectPages.STATE_INFO;
+ trans.destURI = RedirectPages.VS_REMOVE_SUCCESS;
+ trans.errorURI = RedirectPages.VS_REMOVE_NG;
+ session.setAttribute(SessionKeys.PAGE_TRANSDATA, trans);
+ }
+ else {
+ MessageView error = new MessageView(41182, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11411 VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+
+ try {
+ thread.setExecute(mode,vs);
+ thread.start();
+ }
+ catch(Exception e)
+ {
+ MessageView error = new MessageView(41183, LogCategorySet.GUI_VIRTUALSERVICE,
+ Message.UNEXPECTED_ERROR);
+ session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
+ response.sendRedirect(RedirectPages.LOGIN);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11412 VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+ response.sendRedirect(redirectPage);
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11413 VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out");
+ }
+ // --- debug log (out method) ---
+ return;
+ }
+}
--- /dev/null
+package org.ultramonkey.l7.view;
+
+import java.util.HashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.log4j.Logger;
+import org.ultramonkey.l7.controller.EndPoint;
+import org.ultramonkey.l7.controller.VirtualSetting;
+import org.ultramonkey.l7.model.LogCategorySet;
+import org.ultramonkey.l7.model.Message;
+
+/**
+ * <p>
+ * class ValidationCheck
+ * </p>
+ * <p>
+ * Copyright(c) NTT COMWARE 2008
+ * </p>
+ *
+ * @author kubota
+ */
+public class ValidationCheck {
+
+ private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO);
+
+ public ValidationCheck() {
+ // --- debug log (constructor) ---
+ if (logger.isDebugEnabled()) {
+ logger.debug("11336 class ValidationCheck created.");
+ }
+ // --- debug log (constructor) ---
+ }
+
+ /**
+ *
+ * <p>
+ * validationCheck method
+ * </p>
+ *
+ * @param inputVsMap
+ * @param invalidMap
+ * @param vs
+ */
+ public boolean vsCheck(HashMap<String, String> inputVsMap,
+ HashMap<String, String> invalidMap, VirtualSetting vs) {
+ // --- debug log (in method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("ValidationCheck::vsCheck(HashMap<String, String> inputVsMap, HashMap<String, String> invalidMap, VirtualSetting vs) in ");
+ buf.append("inputVsMap=(" + inputVsMap + "), ");
+ buf.append("invalidMap=(" + invalidMap + "), ");
+ buf.append("vs=(" + vs + ")");
+ logger.debug("11337 " + buf.toString());
+ }
+ // --- debug log (in method) ---
+
+ boolean validationFlag = true;
+
+ final int MIN_IP = 0;
+ final int MAX_IP = 255;
+ final int PARTITION = 4;
+ final int MIN_PORT = 1;
+ final int MAX_PORT = 65535;
+ final int MAX_PORT_LENGTH = 10;
+ final int MAX_OPTION_LENGTH = 127;
+ final long MIN_QOS_SERVICE = 0L;
+ final long MAX_QOS_SERVICE = 999L;
+ final long MIN_QOS_CON = 0L;
+ final long MAX_QOS_CON = 999L;
+ final int MIN_CON = 0;
+ final int MAX_CON = 100000;
+ final int MIN_TIME_OUT = 1;
+ final int MAX_TIME_OUT = Integer.MAX_VALUE;
+ final int MAX_CHECK_TYPE_LENGTH = 10;
+ final int DOWN_CALLBACK_LENGTH = 127;
+ final int UP_CALLBACK_LENGTH = 127;
+ final int MIN_CHECKPORT = 1;
+ final int MAX_CHECKPORT = 65535;
+ final int MAX_REQUEST_LENGTH = 127;
+ final int MAX_RECEIVE_LENGTH = 127;
+ final int MAX_VIRTUAL_HOST_LENGTH = 127;
+ final int MAX_LOGIN_USER_LENGTH = 32;
+ final int MAX_LOGIN_PASS_LENGTH = 32;
+ final int MAX_DB_LENGTH = 32;
+ final int MIN_WEIGHT = 0;
+ final int MAX_WEIGHT = 100;
+
+ // VirtualService IP validationCheck
+ String vip = inputVsMap.get("vip");
+ if (vip == null || vip.length() == 0) {
+ invalidMap.put("vip", Message.REQUIED_ITEM);
+ validationFlag = false;
+ } else {
+ if (vip.equals("0.0.0.0")) {
+ invalidMap.put("vip", Message.INVALID_VALUE);
+ validationFlag = false;
+ } else {
+ String tmp_vip[] = vip.split("\\.", PARTITION);
+ int int_vip = 0;
+
+ if (tmp_vip.length != PARTITION) {
+ invalidMap.put("vip", Message.INVALID_VALUE);
+ validationFlag = false;
+ } else {
+ for (int i = 0; i < PARTITION; i++) {
+ try {
+ int_vip = Integer.parseInt(tmp_vip[i]);
+ if ((int_vip < MIN_IP) || (int_vip > MAX_IP)) {
+ invalidMap.put("vip", Message.INVALID_VALUE);
+ validationFlag = false;
+ break;
+ }
+ } catch (NumberFormatException e) {
+ invalidMap.put("vip", Message.INVALID_VALUE);
+ validationFlag = false;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (vip != null)
+ vs.virtual.host = vip;
+
+ // VirtualService Port validationCheck
+ String port = inputVsMap.get("port");
+ if (port == null || port.length() == 0) {
+ invalidMap.put("port", Message.REQUIED_ITEM);
+ validationFlag = false;
+ } else {
+ try {
+ int int_port = Integer.parseInt(port);
+ if ((int_port < MIN_PORT) || ((int_port > MAX_PORT))) {
+ invalidMap.put("port", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ } catch (NumberFormatException e) {
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+ Matcher matcher = pattern.matcher(port);
+ if ((port.length() > MAX_PORT_LENGTH) || matcher.find()) {
+ invalidMap.put("port", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ vs.virtual.port = port;
+ }
+
+ // Protomod validationCheck
+ String protomod = inputVsMap.get("protomod");
+ if (protomod != null && protomod.length() == 0) {
+ invalidMap.put("protomod", Message.REQUIED_ITEM);
+ validationFlag = false;
+ } else if (protomod == null
+ || (!protomod.equals("cinsert") && !protomod.equals("url")
+ && !protomod.equals("sslid") && !protomod
+ .equals("sessionless"))) {
+ invalidMap.put("protomod", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ if (protomod != null)
+ vs.protomod = protomod;
+
+ // Persistence option validationCheck
+ String option = inputVsMap.get("option");
+ if (option != null && option.length() > 0) {
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+ Matcher matcher = pattern.matcher(option);
+ if ((option.length() > MAX_OPTION_LENGTH) || matcher.find()) {
+ invalidMap.put("option", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ if (option != null)
+ vs.option = option;
+ if (vs.getKey() == null) {
+ invalidMap.put("option", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+
+ // Scheduler Type validationCheck
+ String sched = inputVsMap.get("sched");
+ if (sched != null && sched.length() == 0) {
+ invalidMap.put("sched", Message.REQUIED_ITEM);
+ validationFlag = false;
+ } else if (sched == null
+ || (!sched.equals("rr") && !sched.equals("wrr") && !sched
+ .equals("lc"))) {
+ invalidMap.put("sched", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ if (sched != null)
+ vs.sched = sched;
+
+ // QoS (per Virtual Service) validationCheck
+ String qos_service = inputVsMap.get("qos_service");
+ String qos_service_unit = inputVsMap.get("qos_service_unit");
+ if (qos_service != null && qos_service.length() > 0) {
+ long long_qos_service = 0;
+ try {
+ long_qos_service = Long.parseLong(qos_service);
+ if ((long_qos_service < MIN_QOS_SERVICE)
+ || (long_qos_service > MAX_QOS_SERVICE)) {
+ invalidMap.put("qos_service", Message.INVALID_VALUE);
+ validationFlag = false;
+ } else {
+ if (qos_service_unit != null && qos_service_unit.equals("bps")) {
+ } else if (qos_service_unit != null && qos_service_unit.equals("Kbps")) {
+ long_qos_service = long_qos_service * 1000;
+ } else if (qos_service_unit != null && qos_service_unit.equals("Mbps")) {
+ long_qos_service = long_qos_service * 1000000;
+ } else if (qos_service_unit != null && qos_service_unit.equals("Gbps")) {
+ long_qos_service = long_qos_service * 1000000000;
+ } else {
+ invalidMap.put("qos_service", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ } catch (NumberFormatException e) {
+ invalidMap.put("qos_service", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ vs.qosservice = long_qos_service;
+ }
+
+ // QoS (per Client) validationCheck
+ String qos_conn = inputVsMap.get("qos_conn");
+ String qos_conn_unit = inputVsMap.get("qos_conn_unit");
+ if (qos_conn != null && qos_conn.length() > 0) {
+ long long_qos_conn = 0;
+ try {
+ long_qos_conn = Long.parseLong(qos_conn);
+ if ((long_qos_conn < MIN_QOS_CON)
+ || (long_qos_conn > MAX_QOS_CON)) {
+ invalidMap.put("qos_conn", Message.INVALID_VALUE);
+ validationFlag = false;
+ } else {
+ if (qos_conn_unit != null && qos_conn_unit.equals("bps")) {
+ } else if (qos_conn_unit != null && qos_conn_unit.equals("Kbps")) {
+ long_qos_conn = long_qos_conn * 1000;
+ } else if (qos_conn_unit != null && qos_conn_unit.equals("Mbps")) {
+ long_qos_conn = long_qos_conn * 1000000;
+ } else if (qos_conn_unit != null && qos_conn_unit.equals("Gbps")) {
+ long_qos_conn = long_qos_conn * 1000000000;
+ } else {
+ invalidMap.put("qos_conn", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ } catch (NumberFormatException e) {
+ invalidMap.put("qos_conn", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ vs.qosclient = long_qos_conn;
+ }
+
+ // Max Connections validationCheck
+ String max_conn = inputVsMap.get("max_conn");
+ if (max_conn != null && max_conn.length() > 0) {
+ int int_max_conn = 0;
+ try {
+ int_max_conn = Integer.parseInt(max_conn);
+ if ((int_max_conn < MIN_CON) || (int_max_conn > MAX_CON)) {
+ invalidMap.put("max_conn", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ } catch (NumberFormatException e) {
+ invalidMap.put("max_conn", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ vs.maxconn = int_max_conn;
+ }
+
+ // Timeout validationCheck
+ String timeout = inputVsMap.get("timeout");
+ if (timeout != null && timeout.length() > 0) {
+ int int_timeout = 0;
+ try {
+ int_timeout = Integer.parseInt(timeout);
+ if ((int_timeout < MIN_TIME_OUT)
+ || (int_timeout > MAX_TIME_OUT)) {
+ invalidMap.put("timeout", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ } catch (NumberFormatException e) {
+ invalidMap.put("timeout", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ vs.timeout = int_timeout;
+ }
+
+ // Check Type validationCheck
+ String check_type = inputVsMap.get("check_type");
+ if (check_type != null && (check_type.length() > 0)
+ && (check_type.length() < MAX_CHECK_TYPE_LENGTH)) {
+ Pattern pattern = Pattern.compile("[0-9]");
+ Matcher matcher = pattern.matcher(check_type);
+ if (!matcher.matches() && !check_type.equals("negotiate")
+ && !check_type.equals("connect")
+ && !check_type.equals("ping") && !check_type.equals("off")
+ && !check_type.equals("on")) {
+ invalidMap.put("check_type", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ if (check_type != null)
+ vs.checktype = check_type;
+
+ // Check Service validationCheck
+ String check_service = inputVsMap.get("check_service");
+ if (check_service != null && check_service.length() > 0) {
+ if (!check_service.equals("ftp") && !check_service.equals("smtp")
+ && !check_service.equals("dns")
+ && !check_service.equals("http")
+ && !check_service.equals("pop")
+ && !check_service.equals("nntp")
+ && !check_service.equals("imap")
+ && !check_service.equals("ldap")
+ && !check_service.equals("https")
+ && !check_service.equals("mysql")
+ && !check_service.equals("pgsql")
+ && !check_service.equals("dns")
+ && !check_service.equals("sip")
+ && !check_service.equals("none")) {
+ invalidMap.put("check_service", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ if (check_service != null)
+ vs.service = check_service;
+
+ // Quiescent validationCheck
+ String quiescent = inputVsMap.get("quiescent");
+ if (quiescent != null && quiescent.length() > 0) {
+ if (!quiescent.equals("yes") && !quiescent.equals("no")) {
+ invalidMap.put("quiescent", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ if (quiescent != null)
+ vs.quiescent = quiescent;
+
+ // Real Server Down Callback validationCheck
+ String down_callback = inputVsMap.get("down_callback");
+ if ( (down_callback != null) && down_callback.length() > 0){
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+ Matcher matcher = pattern.matcher(down_callback);
+ if ((down_callback.length() > DOWN_CALLBACK_LENGTH) || matcher.find()){
+ invalidMap.put("down_callback", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ if (down_callback != null)
+ vs.downcallback = down_callback;
+
+
+ // Real Server Up Callback validationCheck
+ String up_callback = inputVsMap.get("up_callback");
+ if ( (up_callback != null) && (up_callback.length() > 0) ){
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+ Matcher matcher = pattern.matcher(up_callback);
+ if ( (up_callback.length() > UP_CALLBACK_LENGTH) || matcher.find() ) {
+ invalidMap.put("up_callback", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ if (up_callback != null)
+ vs.upcallback = up_callback;
+
+
+ // CheckPort validationCheck
+ String check_port = inputVsMap.get("check_port");
+ if (check_port != null && check_port.length() > 0) {
+ int int_checkport = 0;
+ try {
+ int_checkport = Integer.parseInt(check_port);
+ if ((int_checkport < MIN_CHECKPORT)
+ || (int_checkport > MAX_CHECKPORT)) {
+ invalidMap.put("check_port", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ } catch (NumberFormatException e) {
+ invalidMap.put("check_port", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ vs.checkport = int_checkport;
+ }
+
+
+ // Request Path validationCheck
+ String request = inputVsMap.get("request");
+ if (request != null && request.length() > 0) {
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+ Matcher matcher = pattern.matcher(request);
+ if ( (request.length() > MAX_REQUEST_LENGTH) || matcher.find() ) {
+ invalidMap.put("request", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ if (request != null)
+ vs.request = request;
+
+
+ // Receive String validationCheck
+ String receive = inputVsMap.get("receive");
+ if (receive != null && receive.length() > 0) {
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+ Matcher matcher = pattern.matcher(receive);
+ if ( (receive.length() > MAX_RECEIVE_LENGTH) || matcher.find() ) {
+ invalidMap.put("receive", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ if (receive != null)
+ vs.receive = receive;
+
+
+ // HTTP Method validationCheck
+ String method = inputVsMap.get("method");
+ if (method != null && method.length() > 0) {
+ if (!method.equals("GET") && !method.equals("HEAD")) {
+ invalidMap.put("method", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ if (method != null)
+ vs.httpmethod = method;
+
+ // Virtual Host validationCheck
+ String virtual_host = inputVsMap.get("virtual_host");
+ if (virtual_host != null && virtual_host.length() > 0) {
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+ Matcher matcher = pattern.matcher(virtual_host);
+ if ( (virtual_host.length() > MAX_VIRTUAL_HOST_LENGTH) || matcher.find()) {
+ invalidMap.put("virtual_host", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ if (virtual_host != null)
+ vs.virtualhost = virtual_host;
+
+
+ // Login Username validationCheck
+ String login_user = inputVsMap.get("login_user");
+ if ( (login_user != null) && (login_user.length() > 0) ) {
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+ Matcher matcher = pattern.matcher(login_user);
+
+ if ( (login_user.length() > MAX_LOGIN_USER_LENGTH) || matcher.find() ) {
+ invalidMap.put("login_user", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ if (login_user != null)
+ vs.login = login_user;
+
+
+ // Login Password validationCheck
+ String login_pass = inputVsMap.get("login_pass");
+ if ( (login_pass != null) && (login_pass.length() > 0) ){
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+ Matcher matcher = pattern.matcher(login_pass);
+ if ( (login_pass.length() > MAX_LOGIN_PASS_LENGTH) || matcher.find() ) {
+ invalidMap.put("login_pass", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ if (login_pass != null)
+ vs.passwd = login_pass;
+
+
+ // Database Name validationCheck
+ String db = inputVsMap.get("db");
+ if ( (db != null) && (db.length() > 0) ) {
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+ Matcher matcher = pattern.matcher(db);
+ if ( (db.length() > MAX_DB_LENGTH) || matcher.find() ) {
+ invalidMap.put("db", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ if (db != null)
+ vs.database = db;
+
+
+ // RealServer Info(IP,Port.Weight) validationCheck
+ int num = 1;
+ while (true) {
+ // Serch EndPoint
+ String rs_ip = inputVsMap.get("rs" + num + "_ip");
+ if (rs_ip == null)
+ break;
+
+ String rs_port = inputVsMap.get("rs" + num + "_port");
+ if (rs_port == null)
+ break;
+
+ String rs_weight = inputVsMap.get("rs" + num + "_weight");
+ if (rs_weight == null)
+ break;
+
+ if (rs_ip.length() == 0 && rs_port.length() == 0
+ && rs_weight.length() == 0) {
+ num++;
+ continue;
+ } else {
+ // IP
+ if (rs_ip.length() == 0) {
+ invalidMap.put("rs" + num + "_ip", Message.REQUIED_ITEM);
+ validationFlag = false;
+ } else {
+ if (rs_ip.equals("0.0.0.0")) {
+ invalidMap.put("rs" + num + "_ip", Message.INVALID_VALUE);
+ validationFlag = false;
+ } else {
+ String tmp_rs_addr[] = rs_ip.split("\\.", PARTITION);
+ int int_rs_addr = 0;
+
+ if (tmp_rs_addr.length != PARTITION) {
+ invalidMap.put("rs" + num + "_ip",
+ Message.INVALID_VALUE);
+ validationFlag = false;
+ } else {
+ for (int i = 0; i < PARTITION; i++) {
+ try {
+ int_rs_addr = Integer
+ .parseInt(tmp_rs_addr[i]);
+ if ((int_rs_addr < MIN_IP)
+ || (int_rs_addr > MAX_IP)) {
+ invalidMap.put("rs" + num + "_ip",
+ Message.INVALID_VALUE);
+ validationFlag = false;
+ break;
+ }
+ } catch (NumberFormatException e) {
+ invalidMap.put("rs" + num + "_ip",
+ Message.INVALID_VALUE);
+ validationFlag = false;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ // Port
+ if (rs_port.length() == 0) {
+ invalidMap.put("rs" + num + "_port", Message.REQUIED_ITEM);
+ validationFlag = false;
+ } else {
+ try {
+ int int_rs_port = Integer.parseInt(rs_port);
+ if ((int_rs_port < MIN_PORT)
+ || (int_rs_port > MAX_PORT)) {
+ invalidMap.put("rs" + num + "_port",
+ Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ } catch (NumberFormatException e) {
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+ Matcher matcher = pattern.matcher(rs_port);
+ if ((rs_port.length() > MAX_PORT_LENGTH) || matcher.find()) {
+ invalidMap.put("rs" + num + "_port", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ }
+
+ // Weight
+ int int_rs_weight = 1;
+ if (rs_weight.length() == 0) {
+ invalidMap
+ .put("rs" + num + "_weight", Message.REQUIED_ITEM);
+ validationFlag = false;
+ } else {
+ try {
+ int_rs_weight = Integer.parseInt(rs_weight);
+ if ((int_rs_weight < MIN_WEIGHT)
+ || (int_rs_weight > MAX_WEIGHT)) {
+ invalidMap.put("rs" + num + "_weight",
+ Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ } catch (NumberFormatException e) {
+ invalidMap.put("rs" + num + "_weight",
+ Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+
+ EndPoint rs = new EndPoint(rs_ip, rs_port, int_rs_weight,
+ 0, 0);
+ vs.real.add(rs);
+ }
+ num++;
+ }
+
+ // SorryServer_IP validationCheck
+ String sorry_ip = inputVsMap.get("sorry_ip");
+ if (sorry_ip != null && sorry_ip.length() > 0) {
+ if (sorry_ip.equals("0.0.0.0")) {
+ invalidMap.put("sorry_ip", Message.INVALID_VALUE);
+ validationFlag = false;
+ } else {
+ String tmp_sorry_ip[] = sorry_ip.split("\\.", PARTITION);
+ int int_sorry_ip = 0;
+ if (tmp_sorry_ip.length != PARTITION) {
+ invalidMap.put("sorry_ip", Message.INVALID_VALUE);
+ validationFlag = false;
+ } else {
+ for (int i = 0; i < PARTITION; i++) {
+ try {
+ int_sorry_ip = Integer.parseInt(tmp_sorry_ip[i]);
+ if ((int_sorry_ip < MIN_IP)
+ || (int_sorry_ip > MAX_IP)) {
+ invalidMap.put("sorry_ip",
+ Message.INVALID_VALUE);
+ validationFlag = false;
+ break;
+ }
+ } catch (NumberFormatException e) {
+ invalidMap.put("sorry_ip", Message.INVALID_VALUE);
+ validationFlag = false;
+ break;
+ }
+ }
+ }
+ }
+ vs.sorryserver.host = sorry_ip;
+ }
+
+ // SorryServer Port validationCheck
+ String sorry_port = inputVsMap.get("sorry_port");
+ if (sorry_port != null && sorry_port.length() > 0) {
+ try {
+ int int_sorry_port = Integer.parseInt(sorry_port);
+ if ((int_sorry_port < MIN_PORT) || (int_sorry_port > MAX_PORT)) {
+ invalidMap.put("sorry_port", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ } catch (NumberFormatException e) {
+ Pattern pattern = Pattern.compile("[^\\x20-\\x7e]");
+ Matcher matcher = pattern.matcher(sorry_port);
+ if ((sorry_port.length() > MAX_PORT_LENGTH) || matcher.find()) {
+ invalidMap.put("sorry_port", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+ vs.sorryserver.port = sorry_port;
+ }
+
+ // SorryFlag validationCheck
+ String sorry_flag = inputVsMap.get("sorry_flag");
+ vs.sorryflag = false;
+ if (sorry_flag != null && sorry_flag.length() > 0) {
+ if (sorry_flag.equals("on")) {
+ vs.sorryflag = true;
+ } else if (sorry_flag.equals("off")) {
+ vs.sorryflag = false;
+ } else {
+ invalidMap.put("sorry_flag", Message.INVALID_VALUE);
+ validationFlag = false;
+ }
+ }
+
+ // --- debug log (out method) ---
+ if (logger.isDebugEnabled()) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("ValidationCheck::vsCheck(HashMap<String, String> inputVsMap, HashMap<String, String> invalidMap, VirtualSetting vs) out ");
+ buf.append("return=" + validationFlag);
+ logger.debug("11338 " + buf.toString());
+ }
+ // --- debug log (out method) ---
+ return validationFlag;
+ }
+}