001/* 002 * Copyright (c) 2009 The openGion Project. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 013 * either express or implied. See the License for the specific language 014 * governing permissions and limitations under the License. 015 */ 016package org.opengion.hayabusa.servlet; 017 018import org.opengion.fukurou.system.OgRuntimeException ; // 6.4.2.0 (2016/01/29) 019import java.io.File; 020import java.io.IOException; 021import java.io.PrintWriter; 022import java.lang.reflect.Field; 023import java.net.URL; 024import java.util.Enumeration; 025import java.util.Map; 026import java.util.concurrent.ConcurrentMap; // 6.4.3.3 (2016/03/04) 027import java.util.jar.JarEntry; 028import java.util.jar.JarFile; 029 030import javax.servlet.ServletContext; 031import javax.servlet.ServletException; 032import javax.servlet.http.HttpServlet; 033import javax.servlet.http.HttpServletRequest; 034import javax.servlet.http.HttpServletResponse; 035import javax.servlet.http.HttpSession; 036 037import org.opengion.fukurou.db.ConnectionFactory; 038import org.opengion.fukurou.util.Attributes; 039import org.opengion.fukurou.util.HybsEntry; 040import org.opengion.fukurou.util.StringUtil; 041import org.opengion.fukurou.system.BuildNumber; // 6.4.2.0 (2016/01/29) hayabusa.common.BuildNumber → fukurou.system.BuildNumber に移動 042import org.opengion.fukurou.system.Closer ; // 5.5.2.6 (2012/05/25) 043import org.opengion.hayabusa.common.HybsSystem; 044import org.opengion.hayabusa.common.SystemManager; 045import org.opengion.hayabusa.common.SystemParameter; 046import org.opengion.hayabusa.common.UserSummary; 047import static org.opengion.fukurou.system.HybsConst.CR ; // 6.1.0.0 (2014/12/26) 048import static org.opengion.fukurou.system.HybsConst.BUFFER_MIDDLE; // 6.1.0.0 (2014/12/26) refactoring 049 050import org.opengion.hayabusa.resource.ResourceFactory; // 5.9.1.0 (2015/10/02) 051import org.opengion.hayabusa.resource.UserInfo; // 5.9.1.0 (2015/10/02) 052 053import javax.servlet.ServletRegistration; // 6.3.4.0 (2015/08/01) 054import javax.servlet.FilterRegistration; // 6.3.4.0 (2015/08/01) 055 056/** 057 * サーバー管理情報を取得するAdminサーブレットです。 058 * 059 * 引数(URL)に応じて、サーバーの状態結果を返します。 060 * 一般には、http://サーバー:ポート/システムID/jsp/admin?COMMAND=コマンド の 061 * 形式のURL でアクセスします。 062 * 063 * ・COMMAND=infomation 064 * 【サーバー情報】 065 * OS情報 = Windows 7 Service Pack 1 x86 (32) 066 * サーバー名 = 10374232-0004 ( 172.27.26.164 ) 067 * サーブレット = Apache Tomcat/8.0.22 068 * TOMCAT_HOME = C:\opengionV6\apps\tomcat8.0.22 069 * JDKバージョン = Java HotSpot(TM) Server VM 1.8.0_45-b15 070 * JAVA_HOME = C:\opengionV6\apps\jdk180u45\jre 071 * 【実行環境】 072 * REAL_PATH = C:/opengionV6/uap/webapps/gf/ 073 * バージョンNo = openGion 6.2.4.0 Release6 Builds (2015142) 074 * 作成日時 = 2015/05/22 15:31:53 075 * 【ログイン情報】 076 * ログイン人数 = 2 名 ( 明細情報 ) 077 * 【メモリ情報】 078 * 空きメモリ = 129 [MByte] 079 * 合計メモリ = 209 [MByte] 080 * 使用率 = 38 [%] 081 * 【ディスク情報】 082 * 083 * ・COMMAND=close 084 * リソース情報のキャッシュを全てクリアします。 085 * 086 * ・COMMAND=loginUser 087 * 現在のログインユーザーの明細情報を表示します。 088 * SORT=[JNAME,ID,ROLES,IPADDRESS,LOGINTIME] ソートキー 089 * DIREC=[true,false] true:昇順/false:降順 090 *<del> 091 * ・COMMAND=plugin 092 * 現在のプラグインのバージョン情報を表示します。 093 *</del> 094 * ・COMMAND=systemResource 095 * 現在のシステムリソースの設定情報を表示します。 096 * 097 * ・COMMAND=AccessStop&stop=[true/false] 098 * アクセスストップフィルターの制御(停止、許可)を行います。 099 *<del> 100 * ※ 6.4.4.1 (2016/03/18) 101 * ・COMMAND=commonMessage&type=[set/clear]&message=共通情報 102 * 共通情報を登録します。errorMessageタグに表示されます。 103 *</del> 104 * ・common/gamen/01_ADMIN/parameter.jsp 105 * 現在のシステムリソースの設定情報を表示します。 106 * 107 * ・common/gamen/01_ADMIN/systemInfo.jsp 108 * システム定数のシステム起動情報を表示します。 109 * 110 * ※ 7.1.0.0 (2020/01/20) 111 * ・common/gamen/01_ADMIN/logLink.jsp 112 * Tomcatのlogを表示します。 113 * 114 * ※ 7.1.0.0 (2020/01/20) 115 * ・common/gamen/01_ADMIN/serviceRestart.jsp 116 * Tomcatのサービスを再起動(停止―開始)します。 117 * 118 * @og.rev 3.5.3.0 (2003/10/27) Admin JSP を Servlet化して、エンジンと共に供給します。 119 * @og.rev 4.0.0.0 (2005/08/31) プラグインのバージョン情報の表示機能を追加 120 * @og.group その他機能 121 * 122 * @version 4.0 123 * @author Kazuhiko Hasegawa 124 * @since JDK5.0, 125 */ 126public final class HybsAdmin extends HttpServlet { 127 private static final long serialVersionUID = 624120150522L ; // 6.2.4.1 (2015/05/22) 128 129 private static final String JSP = HybsSystem.sys( "JSP" ); // jspフォルダの正規パス 130 131 private static final long MB = 1024*1024 ; // 6.2.4.1 (2015/05/22) 132 private static final long GB = 1024*1024*1024 ; // 6.2.4.1 (2015/05/22) 133 134// private static final String HEADER = 135// "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + CR + 136// "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" + CR + 137// " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" + CR + 138// "<html xmlns=\"http://www.w3.org/1999/xhtml\" >" + CR + 139// "<head>" + CR + 140// " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />" + CR + 141// " <meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />" + CR + 142// " <link rel=\"stylesheet\" href=\"" + JSP + "/common/default.css\" type=\"text/css\" />" + CR + 143// " <link rel=\"stylesheet\" href=\"" + JSP + "/custom/custom.css\" type=\"text/css\" />" + CR + 144// " <title>Hybs Admin</title>" + CR + 145// "</head>" + CR; 146 147 // 7.0.1.0 (2018/10/15) XHTML → HTML5 対応 148 private static final String HEADER = 149 "<!DOCTYPE html>" + CR + 150 "<html class=\"headtype-query\">" + CR + 151 "<head>" + CR + 152 " <meta charset=\"UTF-8\" >" + CR + 153 " <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" >" + CR + 154 " <link rel=\"stylesheet\" href=\"" + JSP + "/common/default.css\" type=\"text/css\" >" + CR + 155 " <link rel=\"stylesheet\" href=\"" + JSP + "/custom/custom.css\" type=\"text/css\" >" + CR + 156 " <title>Hybs Admin</title>" + CR + 157 "</head>" + CR; 158 159 // 3.5.3.1 (2003/10/31) User情報のテーブルの設定を、システムリソース より行う。 160 private static final String TABLE_HEADER = getTableHeaderTag() ; 161 162 // 7.1.0.0 (2020/01/20) static定義をやめて、getInfomation() メソッド内で都度呼びます。 163// private static final String SERVER_INFO = HybsSystem.sys( "SERVER_INFO" ); // 10374232-0004 ( 200.1.50.239 ) 164// private static final String SERVLET_INFO = HybsSystem.sys( "SERVLET_INFO" ); // Apache Tomcat/7.0.39 165// private static final String REAL_PATH = HybsSystem.sys( "REAL_PATH" ); // C:/opengion/uap/webapps/gf/ 166// private static final String TOMCAT_HOME = HybsSystem.sys( "TOMCAT_HOME" ); // C:/opengion/apps/tomcat5.5.17 167// private static final String JAVA_HOME = HybsSystem.sys( "JAVA_HOME" ); // C:/opengion/apps/jdk170u25/jre 168// 169// // 7.1.0.0 (2020/01/20) OFFICE_HOME,EXT_DIR,SYS_LOG_URL,LOGS_DIR 環境変数の追加 170// private static final String SYS_LOG_URL = HybsSystem.sys( "SYS_LOG_URL" ); // 7.1.0.0 (2020/01/20) jsp以下のログファイル名 171// private static final String LOGS_DIR = HybsSystem.sys( "LOGS_DIR" ); // 7.1.0.0 (2020/01/20) Tomcatのログフォルダ 172// private static final String OFFICE_HOME = HybsSystem.sys( "OFFICE_HOME" ); // 7.1.0.0 (2020/01/20) オフィースのHOME 173// private static final String EXT_DIR = HybsSystem.sys( "EXT_DIR" ); // 7.1.0.0 (2020/01/20) 拡張jarフォルダ 174// private static final String IS_SERVICE = HybsSystem.sys( "IS_SERVICE" ); // 7.1.0.0 (2020/01/20) サービスなら、true 175 176 // 5.6.6.0 (2013/07/05) getLoginUser( String,boolean ) で、指定するキーを配列で持っておきます。 177 // キーは、SystemManager.getRunningUserSummary 処理内で大文字化されるため、この配列は、表示用と兼用します。 178 private static final String[] USER_KEYS = { "ID","Jname","Roles","IPAddress","LoginTime","LastAccess","LastGamenNm" }; 179 180 // 6.3.6.1 (2015/08/28) <table> 枠の指定と、</table> の static final String 化 181 private static final String TABLE_WAKU = "<table style=\"margin: 0px 0px 0px 20px;\" frame=\"box\" border=\"1px\" cellspacing=\"0px\" cellpadding=\"0px\" " ; 182 private static final String TABLE_END = "</table>" + CR ; 183 184 // 6.4.4.1 (2016/03/18) application オブジェクトに関連付ける 共通メッセージを設定します。 185 // 6.4.9.4 (2016/09/02) アドレスが、/gf/jsp/admin だったので、他のシステムで動かなかった。 186// private static final String COMMON_MESSAGE = "【共通メッセージを表示する場合は、このテキストフィールドに入力してください。】<br />" + CR + 187// "<form method=\"GET\" action=\"admin\" target=\"RESULT\" >" + CR + 188// " <input name=\"message\" size=\"50\" /> " + CR + 189// " <button type=\"submit\" name=\"type\" value=\"set\" >Set</button> " + CR + 190// " <button type=\"submit\" name=\"type\" value=\"clear\" >Clear</button>" + CR + 191// " <input type=\"hidden\" name=\"COMMAND\" value=\"commonMessage\" />" + CR + 192// "</form><br /><br />" + CR ; 193 194 // 7.0.1.0 (2018/10/15) XHTML → HTML5 対応(空要素の、"/>" 止めを、">" に変更します)。 195 private static final String COMMON_MESSAGE = 196 "【共通メッセージを表示する場合は、このテキストフィールドに入力してください。】<br>" + CR + 197 "<form method=\"GET\" action=\"admin\" target=\"RESULT\" >" + CR + 198 " <input name=\"message\" size=\"50\" >" + CR + 199 " <button type=\"submit\" name=\"type\" value=\"set\" >Set</button>" + CR + 200 " <button type=\"submit\" name=\"type\" value=\"clear\" >Clear</button>" + CR + 201 " <input type=\"hidden\" name=\"COMMAND\" value=\"commonMessage\" >" + CR + 202 "</form><br><br>" + CR ; 203 204 // 7.1.0.0 (2020/01/27) static で定義しておきます。 205 private static final String[] PLUGIN_TYPE = new String[] { 206 "Query","Renderer","Editor","DBType","ViewForm", 207 "TableReader","TableWriter","TableFilter","ChartWriter","CalendarQuery", 208 "DBConstValue","Daemon","JspCreate" // 5.6.6.0 (2013/07/05) 追加 209 } ; 210 211 // 7.1.0.0 (2020/01/27) static で定義しておきます。 212 private static final String TD_CMD = " <td> [<a href=\"admin?COMMAND=" ; 213 private static final String TD_QREF= " <td> [<a href=\"common/quickReference.html" ; // クイックリファレンス 専用 214 private static final String TD_GMN = " <td> [<a href=\"common/gamen/01_ADMIN/" ; 215 private static final String YESNO = "\" onclick=\"return confirm( '実行してよろしいでしょうか?' );" ; 216 private static final String TGT = "\" target=\"RESULT\" >" ; 217 private static final String END_TD = "</a>]</td>" + CR ; 218 219 private static final String INFOMATION = TD_CMD + "infomation" + TGT + "状況表示" + END_TD ; 220 private static final String CLOSE = TD_CMD + "close" + TGT + "プール削除" + END_TD ; 221 private static final String LOGIN_USER = TD_CMD + "loginUser" + TGT + "ログインユーザー" + END_TD ; 222 private static final String QUICK_REFERENCE = TD_QREF + TGT + "クイックリファレンス" + END_TD ; 223 private static final String SYSTEM_RESOURCE = TD_CMD + "systemResource" + TGT + "システムリソース" + END_TD ; 224 private static final String PARAMETER = TD_GMN + "parameter.jsp?GAMENID=01_ADMIN" + TGT + "パラメータ"+ END_TD ; 225 private static final String LOGLINK = TD_GMN + "logLink.jsp" + TGT + "ログ" + END_TD ; 226 private static final String SERVICE_RESTART = TD_GMN + "serviceRestart.jsp" + YESNO + TGT + "サービス再起動" + END_TD ; 227 228 private static final String PLUGIN = TD_CMD + "plugin" + TGT + "プラグイン情報" + END_TD ; 229 private static final String TAGLIB = TD_CMD + "taglib" + TGT + "タグリブ情報" + END_TD ; 230 private static final String REGISTRATION = TD_CMD + "registrationInfo" + TGT + "Servlet/Filter" + END_TD ; 231 private static final String SYSTEM_INFO = TD_GMN + "systemInfo.jsp" + TGT + "システム状況" + END_TD ; 232 private static final String ACCESS_STOP = "<td colspan=\"2\"> アクセス制限" 233 + "[<a href=\"admin?COMMAND=AccessStop&stop=true" + TGT + "停止</a>]/" 234 + "[<a href=\"admin?COMMAND=AccessStop&stop=false" + TGT + "開始" + END_TD ; 235 236 /** 237 * GET メソッドが呼ばれたときに実行します。 238 * 239 * @og.rev 3.5.3.1 (2003/10/31) 機能ごとにメソッドを呼び出すように修正します。 240 * @og.rev 3.5.4.1 (2003/12/01) getAdminLink() メソッドを追加 241 * @og.rev 6.3.8.0 (2015/09/11) AccessStop を外部から制御できるように、コマンドと状態を受けるようにする。 242 * @og.rev 5.9.1.0 (2015/10/02) UserInfoセット機能追加 243 * @og.rev 6.3.8.3 (2015/10/03) Servlet/Filter 情報を作成。 244 * @og.rev 6.3.9.1 (2015/11/27) 3項演算子を || or && で簡素化できる(PMD)。 245 * @og.rev 6.4.4.1 (2016/03/18) application オブジェクトに関連付ける 共通メッセージを設定します。 246 * 247 * @param req HttpServletRequestオブジェクト 248 * @param res HttpServletResponseオブジェクト 249 * 250 * @throws ServletException サーブレット関係のエラーが発生した場合、throw されます。 251 * @throws IOException 入出力エラーが発生したとき 252 */ 253 @Override 254 public void doGet( final HttpServletRequest req, final HttpServletResponse res) 255 throws ServletException, IOException { 256 257 req.setCharacterEncoding( "UTF-8" ); // 6.4.4.1 (2016/03/18) 258 res.setContentType( "text/html; charset=UTF-8" ); 259 final PrintWriter out = res.getWriter(); 260 261 final String command = req.getParameter( "COMMAND" ); 262 263 out.println( HEADER ); 264 out.println( "<body>" ); 265 266// out.print("<h2>"); 267 out.print("<div style=\"font-size:1.5em;\">"); 268 out.print( req.getServerName() ); 269 out.print( ":" ); 270 out.print( req.getServerPort() ); 271 out.print( req.getContextPath() ); 272// out.println("</h2>"); 273 out.println("</div>"); 274 275 if( "infomation".equalsIgnoreCase( command ) ) { 276 out.print( getInfomation() ); 277 } 278 else if( "close".equalsIgnoreCase( command ) ) { 279 out.print( getCloseMessage( req.getSession() ) ); 280 } 281 else if( "loginUser".equalsIgnoreCase( command ) ) { 282 final String sort = req.getParameter( "sort" ); 283 final String direc = req.getParameter( "direc" ); 284 // 6.3.9.1 (2015/11/27) 3項演算子を || or && で簡素化できる(PMD)。 285 final boolean dir = direc == null || Boolean.parseBoolean( direc ); // 6.3.9.1 (2015/11/27) 286 287 out.print( COMMON_MESSAGE ); // 6.4.4.1 (2016/03/18) 288 out.print( getLoginUser(sort,dir) ); 289 } 290 // 6.4.4.1 (2016/03/18) application オブジェクトに関連付ける 共通メッセージを設定します。 291 else if( "commonMessage".equalsIgnoreCase( command ) ) { 292 final String type = req.getParameter( "type" ); 293 final String message = req.getParameter( "message" ); 294 out.print( setCommonMessage( type , message , req.getSession() ) ); 295 } 296 else if( "plugin".equalsIgnoreCase( command ) ) { 297 out.print( getPlugInInfo() ); 298 } 299 else if( "taglib".equalsIgnoreCase( command ) ) { 300 out.print( getTaglibInfo() ); 301 } 302 else if( "systemResource".equalsIgnoreCase( command ) ) { 303 out.print( getSystemResource() ); 304 } 305 // 6.3.8.0 (2015/09/11) AccessStop を外部から制御できるように、コマンドと状態を受けるようにする。 306 else if( "AccessStop".equalsIgnoreCase( command ) ) { 307 out.print( getAccessStop( req.getParameter( "stop" ) ) ); // 6.3.8.0 (2015/09/11) 308 } 309 // 5.9.1.0 (2015/10/02) UserInfoセット機能追加 310 else if( "UserInfo".equalsIgnoreCase( command ) ){ // 5.9.1.0 (2015/10/02) 311 out.print( setUserinfo( req ) ); 312 } 313 // 6.3.8.3 (2015/10/03) Servlet/Filter 情報を作成。 314 else if( "registrationInfo".equalsIgnoreCase( command ) ) { 315 out.print( getRegistrationMessage( req.getSession() ) ); 316 } 317 else { 318 out.print( getAdminLink() ); // 3.5.4.1 (2003/12/01) 追加 319 } 320 321 out.println("</body></html>"); 322 } 323 324 /** 325 * infomation 情報を作成します。 326 * 327 * @og.rev 3.5.3.1 (2003/10/31) 機能ごとにメソッドを呼び出すように修正します。 328 * @og.rev 5.6.7.3 (2013/08/23) TOMCAT_WORKは、TOMCAT_HOME に置き換えます。 329 * @og.rev 6.2.4.1 (2015/05/22) ディスク容量を求めます。 330 * @og.rev 6.3.6.1 (2015/08/28) <table> 枠の指定と、</table> の static final String 化 331 * @og.rev 6.3.9.0 (2015/11/06) 整数値演算なので、Math.round 不要 332 * @og.rev 6.5.0.1 (2016/10/21) ENGINE_INFO は、直接、BuildNumber から取得する。 333 * @og.rev 7.0.1.0 (2018/10/15) XHTML → HTML5 対応(空要素の、"/>" 止めを、">" に変更します)。 334 * @og.rev 7.1.0.0 (2020/01/20) OFFICE_HOME,EXT_DIR,SYS_LOG_URL,LOGS_DIR 環境変数の追加。 335 * 336 * @return infomation情報 337 * @og.rtnNotNull 338 */ 339 private String getInfomation() { 340 // 4.0.0 (2005/01/31) ログイン数の取得方法の変更。 341 final int loginCount = SystemManager.getRunningCount() ; 342 343 final long freeMemory = Runtime.getRuntime().freeMemory()/MB ; // 6.3.9.0 (2015/11/06) 整数値演算なので、Math.round 不要 344 final long totalMemory = Runtime.getRuntime().totalMemory()/MB; // 6.3.9.0 (2015/11/06) 整数値演算なので、Math.round 不要 345 final long useMemoryRatio = (totalMemory-freeMemory)*100/totalMemory ; // 6.3.9.0 (2015/11/06) 整数値演算なので、Math.round 不要 346 final String bgCls = useMemoryRatio <= 50 ? "OK" : useMemoryRatio <= 80 ? "CAUT" : "NG" ; // 6.9.7.0 (2018/05/14) PMD Useless parentheses. 347 348 final StringBuilder rtn = new StringBuilder( BUFFER_MIDDLE ); 349 350 rtn.append( "<table border = \"0px\" >" ); 351// // 7.1.0.0 (2020/01/20) static定義をやめて、getInfomation() メソッド内で都度呼びます。 352// tableTr1( rtn,"サーバー情報" ); 353// tableTr( rtn,"OS情報" , BuildNumber.OS_INFO ); // 6.5.0.1 (2016/10/21) 354// tableTr( rtn,"サーバー名" , SERVER_INFO ); 355// tableTr( rtn,"サーブレット" , SERVLET_INFO ); 356// tableTr( rtn,"TOMCAT_HOME" , TOMCAT_HOME ); // 5.6.7.3 (2013/08/23) 357// tableTr( rtn,"JDKバージョン" , BuildNumber.JDK_INFO ); // 6.5.0.1 (2016/10/21) 358// tableTr( rtn,"JAVA_HOME" , JAVA_HOME ); 359// tableTr( rtn," 拡張フォルダ" , EXT_DIR ); // 7.1.0.0 (2020/01/20) 360// tableTr( rtn,"OFFICE_HOME" , OFFICE_HOME ); // 7.1.0.0 (2020/01/20) 361 362 tableTr1( rtn,"サーバー情報" ); 363 tableTr( rtn,"OS情報" , BuildNumber.OS_INFO ); // 6.5.0.1 (2016/10/21) 364 tableTr( rtn,"サーバー名" , HybsSystem.sys( "SERVER_INFO" ) ); // 10759278-0002 365 tableTr( rtn,"サーブレット" , HybsSystem.sys( "SERVLET_INFO" ) ); // Apache Tomcat/9.0.30 366 tableTr( rtn,"TOMCAT_HOME" , HybsSystem.sys( "TOMCAT_HOME" ) ); // C:/opengionV7/apps/tomcat9.0.30 367 tableTr( rtn," ログフォルダ" , HybsSystem.sys( "TOMCAT_LOGS" ) ); // C:/opengionV7/apps/tomcat9.0.30/logs 368// tableTr( rtn," ログフォルダ" , HybsSystem.sys( "LOGS_DIR" ) ); // C:/opengionV7/uap/bin/../../apps/tomcat9.0.30/logs/10759278-0002/tomcat 369 tableTr( rtn,"JDKバージョン" , BuildNumber.JDK_INFO ); // OpenJDK 64-Bit Server VM 11.0.5+10-LTS 370 tableTr( rtn,"JAVA_HOME" , HybsSystem.sys( "JAVA_HOME" ) ); // C:/opengionV7/apps/jdk11.0.5_10 371 tableTr( rtn," 拡張フォルダ" , HybsSystem.sys( "EXT_DIR" ) ); // C:/opengionV7/uap/bin/../../apps/endorsed7.0.5 372 tableTr( rtn,"OFFICE_HOME" , HybsSystem.sys( "OFFICE_HOME" ) ); // C:/opengionV7/uap/bin/../../apps/LibreOffice_6.3.4 373 374// // 7.1.0.0 (2020/01/20) static定義をやめて、getInfomation() メソッド内で都度呼びます。 375// tableTr1( rtn,"実行環境" ); 376// tableTr( rtn,"REAL_PATH" , REAL_PATH ); 377// tableTr( rtn,"バージョンNo" , BuildNumber.ENGINE_INFO ); // 6.5.0.1 (2016/10/21) 378// tableTr( rtn,"作成日時" , BuildNumber.TIMESTAMP ); 379 380 tableTr1( rtn,"実行環境" ); 381 tableTr( rtn,"サービス起動" , HybsSystem.sys( "IS_SERVICE" ) , " [ " , HybsSystem.sys( "SERVICE_NAME" ) , " ] " ); // true [ サービス名 ] 382 tableTr( rtn,"REAL_PATH" , HybsSystem.sys( "REAL_PATH" ) ); // C:/opengionV7/uap/webapps/gf/ 383 tableTr( rtn,"バージョンNo" , BuildNumber.ENGINE_INFO ); // openGion 7.1.0.0 Release7 Builds (26324783) 384// tableTr( rtn,"jspログファイル" , HybsSystem.sys( "SYS_LOG_URL" ) ); // C:/opengionV7/uap/webapps/gf/log/10759278-0002_tomcat_$(yyyyMM).log 385 tableTr( rtn,"作成日時" , BuildNumber.TIMESTAMP ); // 2020/01/20 11:23:37 386 387 tableTr1( rtn,"ログイン情報" ); 388 tableTr( rtn,"ログイン人数" , String.valueOf( loginCount )," 名 ","( <a href=\"admin?COMMAND=loginUser\">明細情報</a> )" ); 389 390 tableTr1( rtn,"メモリ情報" ); 391 tableTr( rtn,"空きメモリ" , String.valueOf( freeMemory ) , " [MByte]" ); // 6.2.4.1 (2015/05/22) 単位を MB に変更 392 tableTr( rtn,"合計メモリ" , String.valueOf( totalMemory ) , " [MByte]" ); // 6.2.4.1 (2015/05/22) 単位を MB に変更 393 tableTr( rtn,"使用率" , String.valueOf( useMemoryRatio ) , " [%]" ); 394 rtn.append( TABLE_END ) 395 // 6.2.4.1 (2015/05/22) default.css で、memory、disc、discTD を定義 396 .append( TABLE_WAKU ).append( "width=\"300px\" >" ).append( CR ) 397 .append( "\t<tr><td class=\"memory " ).append( bgCls ).append( "\" style=\"width:" ) 398 .append( useMemoryRatio ).append( "%;\" >" ).append( useMemoryRatio ).append( "%</td>" ) 399 .append( "<td class=\"BIT\">" ).append( 100-useMemoryRatio ).append( "%</td></tr>" ).append( CR ) 400 .append( TABLE_END ) 401 402 // 6.2.4.1 (2015/05/22) ディスク容量を求めます。 403 .append( "<table border=\"0px\" >" ).append( CR ); 404 tableTr1( rtn,"ディスク情報" ); 405 rtn.append( TABLE_END ) 406 .append( TABLE_WAKU ).append( "width=\"500px\" >" ).append( CR ) 407 .append( "<th>名前</th><th>合計サイズ</th><th>空き領域</th><th>使用率</th></tr>" ).append( CR ).append( CR ); 408 409 final File[] driv = File.listRoots(); 410 for( final File file : driv ) { 411 // 6.3.9.0 (2015/11/06) 整数値演算なので、Math.round 不要 412 final long total = file.getTotalSpace()/GB ; // パーティションのサイズ 413 final long usable = file.getUsableSpace()/GB ; // 仮想マシンが利用できるバイト数 414 tableTr2( rtn, file.getPath() , total , usable ); // ディスク容量専用3 415 } 416 rtn.append( TABLE_END ) 417 418 // information 419// .append( "<hr />" ).append( CR ) 420 .append( "<hr>" ).append( CR ) // 7.0.1.0 (2018/10/15) XHTML → HTML5 421 .append( "<pre>" ).append( CR ) 422 .append( ConnectionFactory.information() ).append( CR ) 423 .append( "</pre>" ).append( CR ); 424 425 return rtn.toString(); 426 } 427 428 /** 429 * infomation 情報を作成します。 430 * 431 * @og.rev 5.6.6.0 (2013/07/05) </td></tr>漏れ追加 432 * @og.rev 5.6.7.3 (2013/08/23) 前後に、【】を付けます。 433 * 434 * @param buf 情報登録用のStringBuilder 435 * @param key キー 436 * 437 * @return infomation情報(入力bufと同じオブジェクト) 438 * @og.rtnNotNull 439 */ 440 private StringBuilder tableTr1( final StringBuilder buf, final String key ) { 441// buf.append( "\t<tr><td colspan=\"4\"><b>【" ).append( key ).append( "】</b></td></tr>" ).append( CR ); // 【】追加 442// return buf ; 443 return buf.append( "\t<tr><td colspan=\"4\"><b>【" ).append( key ).append( "】</b></td></tr>" ).append( CR ); // 【】追加 444 } 445 446 /** 447 * infomation 情報を作成します。 448 * 449 * @og.rev 5.6.6.0 (2013/07/05) 最初の td に、全角スペース2個 追加 450 * 451 * @param buf 情報登録用のStringBuilder 452 * @param key キー 453 * @param val 値の可変長引数 454 * 455 * @return infomation情報(入力bufと同じオブジェクト) 456 * @og.rtnNotNull 457 */ 458 private StringBuilder tableTr( final StringBuilder buf, final String key, final String... val ) { 459 buf.append( "\t<tr><td width=\"20px\"> </td><td>" ).append( key ).append( "</td><td> = </td><td>" ); // 段を作成する為に、width指定 追加 460 for( int i=0; i<val.length; i++ ) { 461 buf.append( val[i] ); 462 } 463// buf.append( "</td></tr>" ).append( CR ); 464// return buf ; 465 return buf.append( "</td></tr>" ).append( CR ); 466 } 467 468 /** 469 * infomation 情報を作成します。 470 * 471 * @og.rev 6.2.4.1 (2015/05/22) ディスク容量専用 472 * @og.rev 6.2.4.2 (2015/05/29) total が 0 の場合の対応 473 * 474 * @param buf 情報登録用のStringBuilder 475 * @param name ドライブ名 476 * @param total パーティションのサイズ(GB) 477 * @param usable 仮想マシンが利用できるサイズ(GB) 478 * 479 * @return infomation情報(入力bufと同じオブジェクト) 480 * @og.rtnNotNull 481 */ 482 private StringBuilder tableTr2( final StringBuilder buf, final String name, final long total, final long usable ) { 483 final long useRatio = total == 0L ? 0L : (total-usable)*100/total ; // 6.3.9.0 (2015/11/06) findBugs 484 485// final String bgCls = useRatio <= 50 ? "OK" : ( useRatio <= 80 ? "CAUT" : ( useRatio <= 95 ? "WARN" : "NG" ) ) ; 486 final String bgCls = useRatio <= 50 ? "OK" : useRatio <= 80 ? "CAUT" : useRatio <= 95 ? "WARN" : "NG" ; // 6.9.7.0 (2018/05/14) PMD Useless parentheses. 487 488// buf.append( "\t<tr><td class=\"BIT\">" ).append( name ).append( "</td>" ) 489 return buf.append( "\t<tr><td class=\"BIT\">" ).append( name ).append( "</td>" ) 490 .append( "<td class=\"S9\" >" ).append( total ).append( " GB</td>" ) 491 .append( "<td class=\"S9\" >" ).append( usable ).append( " GB</td>" ).append( CR ) 492 .append( "\t\t<td class=\"discTD\" ><span class=\"disc " ).append( bgCls ) 493 .append( "\" style=\"width:" ).append( useRatio ).append( "%;\" >" ) 494 .append( useRatio ).append( "%</span> </td></tr>" ).append( CR ); 495// return buf ; 496 } 497 498 /** 499 * close 情報を作成します。 500 * 501 * @og.rev 3.5.3.1 (2003/10/31) 機能ごとにメソッドを呼び出すように修正します。 502 * @og.rev 3.6.0.0 (2004/09/17) CalendarFactory.clear() を追加します。 503 * @og.rev 4.0.0.0 (2005/01/31) Cleanable インターフェースによる初期化処理 504 * @og.rev 4.1.0.2 (2008/01/29) UserInfoをsessionから消去する(超暫定対応) 505 * @og.rev 5.6.6.0 (2013/07/05) UserSummary の削除処理は、SystemManager から行う。 506 * @og.rev 6.3.7.0 (2015/09/04) ファイナライズを呼び出します。 507 * 508 * @param session HttpSessionオブジェクト 509 * 510 * @return close情報 511 * @og.rtnNotNull 512 */ 513 private String getCloseMessage( final HttpSession session ) { 514 515 // 4.0.0 (2005/01/31) Cleanable インターフェースによる初期化処理 516 SystemManager.allClear( false ) ; 517 518 final ServletContext context = session.getServletContext(); 519 final Map<String,String> param = SystemParameter.makeSystemParameter( context ); 520 HybsSystem.setInitialData( param ); // 4.0.0 (2005/01/31) 521 522 // 5.6.6.0 (2013/07/05) UserSummary の削除処理は、SystemManager から行う。 523 SystemManager.removeSession( session ) ; 524 525 // 6.3.7.0 (2015/09/04) ファイナライズを呼び出します。 526 System.runFinalization(); 527 // System.gc(); // 取りあえず、GCは呼びません。 528 529// final String rtn = "<pre>" 530 return "<pre>" 531 + "キャッシュ情報をクリアしました。" + CR 532 + "ユーザー情報の初期化に関しては、ブラウザを閉じて、再ログインが必要です。" + CR 533 + ConnectionFactory.information() 534 + "</pre>" ; 535// return rtn ; 536 } 537 538 /** 539 * loginUser 情報を作成します。 540 * 541 * @og.rev 3.5.3.1 (2003/10/31) 機能ごとにメソッドを呼び出すように修正します。 542 * @og.rev 3.8.5.3 (2006/08/07) ユーザー情報をソートするためのキー情報を追加 543 * @og.rev 3.8.7.0 (2006/12/15) USER.LASTACCESS情報を追加します。 544 * @og.rev 4.0.0.0 (2005/01/31) DBColumn の 属性(CLS_NM)から、DBTYPEに変更 545 * @og.rev 4.4.0.1 (2009/08/08) 最終ログイン画面名称を追加 546 * @og.rev 5.6.6.0 (2013/07/05) table作成処理を、変更します。 547 * @og.rev 6.3.6.1 (2015/08/28) <table> 枠の指定と、</table> の static final String 化 548 * @og.rev 5.9.1.2 (2015/10/23) 自己終了警告対応 549 * @og.rev 7.0.4.0 (2019/05/31) colgroup 廃止 550 * 551 * @param sort ソートするキー項目を指定 552 * @param direc ソートする方向 [true:昇順/false:降順] 553 * 554 * @return loginUser情報 555 * @og.rtnNotNull 556 */ 557 private String getLoginUser( final String sort,final boolean direc ) { 558 // 4.0.0 (2005/01/31) ログイン数の取得方法の変更。 559 final int loginCount = SystemManager.getRunningCount() ; 560 561 // 4.0.0 (2005/01/31) 562 final UserSummary[] userInfos = SystemManager.getRunningUserSummary( sort,direc ); 563 564 final StringBuilder rtn = new StringBuilder( BUFFER_MIDDLE ) 565 .append( "現在 " ).append( loginCount ).append( " 名の方がログイン中です。" ).append( CR ) 566 .append( "<table " ).append( TABLE_HEADER ).append( " >" ) 567 .append( "<thead><tr><th>No</th>" ); 568 569 // 5.6.6.0 (2013/07/05) table作成処理を、変更します。 570 for( final String sortKey : USER_KEYS ) { 571 rtn.append( "<th><a href=\"?COMMAND=loginUser&sort=" ).append( sortKey ) 572 .append( "&direc=" ).append( !direc ) 573 .append( "\">" ).append( sortKey ).append( "</a></th>" ); 574 } 575 576 // 7.0.4.0 (2019/05/31) colgroup 廃止 577 rtn.append( "</tr></thead>" ).append( CR ) 578// // 5.9.1.2 (2015/10/23) 自己終了警告対応 579// .append( "<colgroup class=\"S9\" ><!-- --></colgroup>" ) 580// .append( "<colgroup class=\"X\" span=\"6\" ><!-- --></colgroup>" ) 581 .append( CR ); 582 583 for( int i=0; i<userInfos.length; i++ ) { 584 final UserSummary userInfo = userInfos[i] ; 585 rtn.append( " <tr class=\"row_" ).append( i%2 ).append( "\" >" ) 586// .append( "<td>" ).append( String.valueOf( i+1 ) ).append( "</td>" ) 587 .append( "<td class='S9'>" ).append( String.valueOf( i+1 ) ).append( "</td>" ) // 7.0.4.0 (2019/05/31) 588 .append( "<td>" ).append( userInfo.getUserID() ).append( "</td>" ) 589 .append( "<td>" ).append( userInfo.getJname() ).append( "</td>" ) 590 .append( "<td>" ).append( userInfo.getRoles() ).append( "</td>" ) 591 .append( "<td>" ).append( userInfo.getIPAddress() ).append( "</td>" ) 592 .append( "<td>" ).append( HybsSystem.getDate( userInfo.getLoginTime() ) ).append( "</td>" ) 593 .append( "<td>" ).append( userInfo.getAttribute( "LASTACCESS" ) ).append( "</td>" ) 594 .append( "<td>" ).append( StringUtil.nval( userInfo.getAttribute( "LASTGAMENNM" ), "" ) ).append( "</td>" ) // 4.4.0.1 (2009/08/08) 595 .append( " </tr>" ).append( CR ); 596 } 597// rtn.append( TABLE_END ); 598 return rtn.append( TABLE_END ).toString(); 599 600// return rtn.toString() ; 601 } 602 603 /** 604 * PlugIn 情報を作成します。 605 * 606 * @og.rev 4.0.0.0 (2005/08/31) 新規作成 607 * @og.rev 5.6.6.0 (2013/07/05) "DBConstValue","Daemon","JspCreate" を、追加します。 608 * @og.rev 7.1.0.0 (2020/01/27) pluginType をstatic で定義しておきます。 609 * 610 * @return PlugIn情報 611 * @og.rtnNotNull 612 */ 613 private String getPlugInInfo() { 614 615// final String[] pluginType = new String[] { 616// "Query","Renderer","Editor","DBType","ViewForm", 617// "TableReader","TableWriter","TableFilter","ChartWriter","CalendarQuery", 618// "DBConstValue","Daemon","JspCreate" // 5.6.6.0 (2013/07/05) 追加 619// } ; 620 621 final ClassInfo info = new ClassInfo(); 622 623// for( int j=0; j<pluginType.length; j++ ) { 624// final String type = pluginType[j] ; 625 for( int j=0; j<PLUGIN_TYPE.length; j++ ) { 626 final String type = PLUGIN_TYPE[j] ; 627 final HybsEntry[] names = HybsSystem.sysEntry( type + "_" ); 628 for( int i=0; i<names.length; i++ ) { 629 final String key = names[i].getKey().substring( type.length()+1 ); 630 final String clsName = names[i].getValue(); 631 info.addLine( type,key,clsName ); 632 } 633 } 634 return info.getClassInfoData() ; 635 } 636 637 /** 638 * Taglib 情報を作成します。 639 * 640 * @og.rev 4.0.0.0 (2006/01/31) 新規作成 641 * @og.rev 5.3.6.0 (2011/06/01) Taglib クラス名の求め方を変更します。(jar版のみ) 642 * @og.rev 5.5.2.6 (2012/05/25) JarFile を、Closer#zipClose( ZipFile ) メソッドを利用して、close します。 643 * @og.rev 6.8.5.1 (2018/01/15) ファイル名は、##バージョン番号を変換しておく必要がある。 644 * 645 * @return Taglib情報 646 * @og.rtnNotNull 647 */ 648 private String getTaglibInfo() { 649 final ClassInfo info = new ClassInfo(); 650 651 // 5.5.2.6 (2012/05/25) findbugs対応 652 JarFile jarFile = null; 653 try { 654 final ClassLoader loader = Thread.currentThread().getContextClassLoader(); 655 final Enumeration<URL> enume = loader.getResources( "org/opengion/hayabusa/taglib/" ); // 4.3.3.6 (2008/11/15) Generics警告対応 656 while( enume.hasMoreElements() ) { 657 final URL url = enume.nextElement(); // 4.3.3.6 (2008/11/15) Generics警告対応 658 // jar:file:/実ディレクトリ または、file:/実ディレクトリ 659// final String dir = url.getFile(); 660 final String dir = url.getFile().replaceAll( "%23%23","##" ); // 6.8.5.1 (2018/01/15) 661 if( "jar".equals( url.getProtocol() ) ) { 662 // dir = file:/G:/webapps/gf/WEB-INF/lib/hayabusa4.0.0.jar!/org/opengion/hayabusa/taglib 形式です。 663 final String jar = dir.substring(dir.indexOf( ':' )+1,dir.lastIndexOf( '!' )); 664 // jar = /G:/webapps/gf/WEB-INF/lib/hayabusa4.0.0.jar 形式に切り出します。 665 jarFile = new JarFile( jar ); 666 final Enumeration<JarEntry> en = jarFile.entries() ; // 4.3.3.6 (2008/11/15) Generics警告対応 667 while( en.hasMoreElements() ) { 668 final JarEntry ent = en.nextElement(); // 4.3.3.6 (2008/11/15) Generics警告対応 669 final String file = ent.getName(); 670 if( ! ent.isDirectory() && file.endsWith( "Tag.class" ) ) { 671 final String type = "Taglib_jar"; 672 // 5.3.6.0 (2011/06/01) Taglib クラス名の求め方を変更します。(jar版のみ) 673 final String key = file.substring( file.lastIndexOf( '/' )+1,file.length()-6 ); // -6 は、.class 分 674 final String clsName = file.replace( '/','.' ).substring( 0,file.length()-6 ); 675 info.addLine( type,key,clsName ); 676 } 677 } 678 Closer.zipClose( jarFile ); // 5.5.2.6 (2012/05/25) findbugs対応 679 jarFile = null; // 正常終了時に、close() が2回呼ばれるのを防ぐため。 680 } 681 else { 682 // dir = /G:/webapps/gf/WEB-INF/classes/org/opengion/hayabusa/taglib/ 形式です。 683 final File[] list = new File( dir ).listFiles(); 684 // 6.3.9.0 (2015/11/06) null になっている可能性がある(findbugs) 685 if( list != null ) { 686 for( final File file : list ) { 687 final String name = file.getName() ; 688 if( file.isFile() && name.endsWith( "Tag.class" ) ) { 689 final String type = "Taglib_file"; 690 final String key = name.substring( 0,name.length()-6 ); 691 final String clsName = "org.opengion.hayabusa.taglib." + key ; 692 info.addLine( type,key,clsName ); 693 } 694 } 695 } 696 } 697 } 698 } 699 catch( final IOException ex ) { 700 final String errMsg = "taglibファイル読み取りストリームを失敗しました。" 701 + CR + ex.getMessage(); 702 throw new OgRuntimeException( errMsg,ex ); 703 } 704 finally { 705 Closer.zipClose( jarFile ); // 5.5.2.6 (2012/05/25) findbugs対応 706 } 707 708 return info.getClassInfoData() ; 709 } 710 711 /** 712 * クラス情報を表示するためのデータを管理します。 713 * ここでは、引数に渡された、分類(Classify)、名称(Key Name)、クラス名(Class Name)、 714 * バージョン(Version)情報をテーブル形式で表示します。 715 * バージョン情報は、クラス名から、インスタンスを作成して、private static final String VERSION 716 * フィールドの値を読み取ります。 717 * 718 * @og.rev 4.0.0.0 (2006/01/31) 新規作成 719 * @og.rev 7.0.4.0 (2019/05/31) colgroup 廃止 720 * @og.rev 7.1.0.0 (2020/01/27) ヘッダー部分をstatic で定義しておきます。 721 */ 722 private static final class ClassInfo { 723 private static final String HEADER = 724 "<table " + TABLE_HEADER + " >" + CR + 725 " <thead><tr><th>No</th><th>Classify</th><th>Key Name</th><th>Class Name</th><th>Version</th></tr></thead>" + CR ; 726 727 private final StringBuilder rtn = new StringBuilder( BUFFER_MIDDLE ); 728 private int cnt; 729 730 /** 731 * コンストラクター 732 * 733 * @og.rev 4.0.0.0 (2006/01/31) 新規作成 734 * @og.rev 5.9.1.2 (2015/10/23) 自己終了警告対応 735 * @og.rev 7.1.0.0 (2020/01/27) ヘッダー部分をstatic で定義しておきます。 736 */ 737 public ClassInfo() { 738 rtn.append( HEADER ); // 7.1.0.0 (2020/01/27) 739 740// // 5.9.1.2 (2015/10/23) 自己終了警告対応。ついでに、append連結しておきます。 741// // 7.0.4.0 (2019/05/31) colgroup 廃止 742// rtn.append( "<table " ).append( TABLE_HEADER ).append( " >" ).append( CR ) 743// .append( " <thead><tr><th>No</th><th>Classify</th><th>Key Name</th><th>Class Name</th><th>Version</th></tr></thead>" ).append( CR ) 744//// .append( " <colgroup class=\"S9\" ><!-- --></colgroup>") 745//// .append( " <colgroup class=\"X\" ><!-- --></colgroup>" ) 746//// .append( " <colgroup class=\"X\" ><!-- --></colgroup>" ) 747//// .append( " <colgroup class=\"X\" ><!-- --></colgroup>" ) 748//// .append( " <colgroup class=\"X\" ><!-- --></colgroup>" ) 749//// .append( " <colgroup class=\"X\" ><!-- --></colgroup>" ) 750// .append( CR ); 751 } 752 753 /** 754 * テーブル表示用のデータを追加します。 755 * 756 * @og.rev 4.0.0.0 (2006/01/31) 新規作成 757 * @og.rev 7.0.4.0 (2019/05/31) colgroup 廃止 758 * 759 * @param type タイプ属性 760 * @param key キー属性 761 * @param clsName クラス名(このクラス名からインスタンス化します。) 762 */ 763 public void addLine( final String type, final String key, final String clsName ) { 764 final String version = getFieldValue( clsName ); 765 766 final boolean isCustom = version.compareTo( BuildNumber.VERSION_NO ) > 0 767 || version.indexOf( "Pache" ) >= 0 768 || version.indexOf( "Nightly" ) >= 0 ; 769 770 final String trType = isCustom ? "warning" : String.valueOf( cnt%2 ); 771 772 rtn.append( "<tr class=\"row_" ).append( trType ).append( "\" >" ) 773// .append( "<td>" ).append( cnt++ ).append( "</td>" ) 774 .append( "<td class='S9'>" ).append( cnt++ ).append( "</td>" ) // 7.0.4.0 (2019/05/31) 775 .append( "<td>" ).append( type ).append( "</td>" ) 776 .append( "<td>" ).append( key ).append( "</td>" ) 777 .append( "<td>" ).append( clsName ).append( "</td>" ) 778 .append( "<td>" ).append( version ).append( "</td>" ) 779 .append( "</tr>" ).append( CR ); 780 } 781 782 /** 783 * すべての内部のデータを文字列化して返します。 784 * 785 * @og.rev 4.0.0.0 (2006/01/31) 新規作成 786 * @og.rev 6.3.6.1 (2015/08/28) <table> 枠の指定と、</table> の static final String 化 787 * 788 * @return 作成されたテーブルデータ 789 * @og.rtnNotNull 790 */ 791 public String getClassInfoData() { 792// rtn.append( TABLE_END ); 793// return rtn.toString() ; 794 return rtn.append( TABLE_END ).toString(); 795 } 796 797 /** 798 * 指定のオブジェクトの VERSION staticフィールドの値を取得します。 799 * 800 * @og.rev 4.0.0.0 (2005/08/31) 新規作成 801 * @og.rev 6.4.3.3 (2016/03/04) HybsSystem#newInstance(String) ではなく、直接Class#forName(String)から、求めます。 802 * 803 * @param clsName 指定のクラスを表す名称 804 * @return VERSIONフィールドの値(エラー時は、そのメッセージ) 805 */ 806 private String getFieldValue( final String clsName ) { 807 String rtn ; 808 try { 809 final Field fld = Class.forName( clsName ).getDeclaredField( "VERSION" ) ; 810 811 // privateフィールドの取得には、accessibleフラグを trueにする必要があります。 812 fld.setAccessible( true ); 813 814 rtn = (String)fld.get( null ); 815 } 816 catch( final Throwable ex ) { 817 rtn = ex.getMessage(); 818 } 819 return rtn ; 820 } 821 } 822 823 /** 824 * systemResource 情報を作成します。 825 * 826 * @og.rev 3.5.3.1 (2003/10/31) 機能ごとにメソッドを呼び出すように修正します。 827 * @og.rev 4.0.0.0 (2005/01/31) DBColumn の 属性(CLS_NM)から、DBTYPEに変更 828 * @og.rev 6.3.6.1 (2015/08/28) <table> 枠の指定と、</table> の static final String 化 829 * @og.rev 5.9.1.2 (2015/10/23) 自己終了警告対応 830 * @og.rev 6.4.3.3 (2016/03/04) 配列返しではなく、Map を返します。 831 * @og.rev 7.0.4.0 (2019/05/31) colgroup 廃止 832 * 833 * @return systemResource情報 834 * @og.rtnNotNull 835 */ 836 private String getSystemResource() { 837 final StringBuilder rtn = new StringBuilder( BUFFER_MIDDLE ) 838 .append( "<table " ).append( TABLE_HEADER ).append( " >" ).append( CR ) 839 .append( "<thead><tr><th>No</th><th>Key</th><th>Value</th></tr></thead>" ).append( CR ) 840// // 5.9.1.2 (2015/10/23) 自己終了警告対応 841// .append( "<colgroup class=\"S9\" ><!-- --></colgroup>" ) 842// .append( "<colgroup class=\"X\" span=\"2\" ><!-- --></colgroup>" ) 843 .append( CR ); 844 845 // 6.4.3.3 (2016/03/04) 配列返しではなく、Map を返します。 846 final ConcurrentMap<String,String> rscMap = HybsSystem.getSystemResourceMap(); 847 int i=0; 848 for( final Map.Entry<String,String> entry : rscMap.entrySet() ) { 849 rtn.append( "<tr class=\"row_" ).append( i%2 ).append( "\" >" ).append( CR ) 850// .append( "<td>" ).append( ++i ).append( "</td>" ) 851 .append( "<td class='S9'>" ).append( ++i ).append( "</td>" ) // 7.0.4.0 (2019/05/31) 852 .append( "<td>" ).append( entry.getKey() ).append( "</td>" ) 853 .append( "<td>" ).append( entry.getValue() ).append( "</td>" ) 854 .append( "</tr>" ).append( CR ); 855 } 856 return rtn.append( TABLE_END ).toString(); 857 } 858 859 /** 860 * AccessStop 情報を作成します。 861 * 862 * @og.rev 3.5.3.1 (2003/10/31) 機能ごとにメソッドを呼び出すように修正します。 863 * @og.rev 4.0.0.0 (2007/11/29) AccessStopFilter#getStopFilter() ⇒ isStopFilter() に変更 864 * @og.rev 6.1.1.0 (2015/01/17) パッケージを import するのと、ロジック見直し。 865 * @og.rev 6.3.8.0 (2015/09/11) AccessStop を外部から制御できるように、コマンドと状態を受けるようにする。 866 * @og.rev 7.1.0.0 (2020/01/20) 本物のサービスと混同しないようにメッセージを変更します。 867 * 868 * @param isStop true:停止/false:実行 869 * @return AccessStop情報 870 * @og.rtnNotNull 871 */ 872 private String getAccessStop( final String isStop ) { 873 874 final boolean flag = Boolean.parseBoolean( isStop ); // 6.3.8.0 (2015/09/11) 875 // AccessStopFilter.setStopFilter( flag ); 876 877// return flag ? "Webアプリケーションのサービスを停止します。" 878// : "Webアプリケーションのサービスを開始します。"; 879 return flag ? "Webアプリケーションへのアクセスを停止します。" 880 : "Webアプリケーションへのアクセスを開始します。"; 881 } 882 883 /** 884 * application オブジェクトに関連付ける 共通メッセージを設定します。 885 * 886 * 取り出しは、errorMessageタグで行います。これは、個々のrequest.jsp に組み込まれている 887 * メッセージなので、ここで登録したメッセージは、同時に、すべてのアクセスしているユーザーが 888 * 見ることになります。 889 * 890 * @og.rev 6.4.4.1 (2016/03/18) application オブジェクトに関連付ける 共通メッセージを設定します。 891 * @og.rev 6.8.5.0 (2018/01/09) 共通メッセージで、strongタグのバグ修正と、class="common_msg" 追加。 892 * @og.rev 7.0.1.0 (2018/10/15) XHTML → HTML5 対応(空要素の、"/>" 止めを、">" に変更します)。 893 * 894 * @param type [set/clear] を指定します。 895 * @param message 共通メッセージを指定します。 896 * @param session HttpSessionオブジェクト 897 * 898 * @return Servlet/Filter情報 899 * @og.rtnNotNull 900 */ 901 private String setCommonMessage( final String type , final String message , final HttpSession session ) { 902 final ServletContext context = session.getServletContext(); 903 904 String rtMsg = ""; 905 if( "set".equalsIgnoreCase( type ) && message != null && message.length() > 0 ) { 906// rtMsg = "<strong class=\"common_msg\">" + message + "</strong><br />"; // 6.8.5.0 (2018/01/09) 907 rtMsg = "<strong class=\"common_msg\">" + message + "</strong><br>"; // 7.0.1.0 (2018/10/15) 908 context.setAttribute( HybsSystem.COMMON_MSG_KEY,rtMsg ); 909 } 910 else if( "get".equalsIgnoreCase( type ) ) { 911 rtMsg = (String)context.getAttribute( HybsSystem.COMMON_MSG_KEY ); 912 } 913 else if( "clear".equalsIgnoreCase( type ) ) { 914 context.removeAttribute( HybsSystem.COMMON_MSG_KEY ); 915 } 916 917 return rtMsg; 918 } 919 920 /** 921 * Servlet/Filter 情報を作成します。 922 * 923 * @og.rev 6.3.8.3 (2015/10/03) Servlet/Filter 情報を作成。 924 * @og.rev 5.9.1.2 (2015/10/23) 自己終了警告対応 925 * @og.rev 7.0.4.0 (2019/05/31) colgroup 廃止 926 * 927 * @param session HttpSessionオブジェクト 928 * 929 * @return Servlet/Filter情報 930 * @og.rtnNotNull 931 */ 932 private String getRegistrationMessage( final HttpSession session ) { 933 final StringBuilder rtn = new StringBuilder( BUFFER_MIDDLE ) 934 // 速度よりソースの見易さ 935 .append( "<table " ).append( TABLE_HEADER ).append( " >" ) 936 .append( "<thead><tr><th>No</th><th>Type</th><th>Key</th><th>Class</th><th>Mappings</th></tr></thead>" ) 937// // 5.9.1.2 (2015/10/23) 自己終了警告対応 938// .append( "<colgroup class=\"S9\" ><!-- --></colgroup>" ) 939// .append( "<colgroup class=\"X\" ><!-- --></colgroup>" ) 940// .append( "<colgroup class=\"X\" ><!-- --></colgroup>" ) 941// .append( "<colgroup class=\"X\" ><!-- --></colgroup>" ) 942// .append( "<colgroup class=\"X\" ><!-- --></colgroup>" ) 943 .append( CR ); 944 945 int no = 0; 946 final ServletContext context = session.getServletContext(); 947 for( final ServletRegistration reg : context.getServletRegistrations().values() ) { 948 // 速度よりソースの見易さ 949 rtn.append( "<tr class=\"row_" ).append( no%2 ).append( "\" >" ) 950// .append( "<td>" ).append( String.valueOf( ++no ) ).append( "</td>" ) 951 .append( "<td class='S9'>" ).append( String.valueOf( ++no ) ).append( "</td>" ) // 7.0.4.0 (2019/05/31) 952 .append( "<td>Servlet</td>" ) 953 .append( "<td>" ).append( reg.getName() ).append( "</td>" ) 954 .append( "<td>" ).append( reg.getClassName() ).append( "</td>" ) 955 .append( "<td>" ).append( reg.getMappings() ).append( "</td>" ) 956 .append( "</tr>" ).append( CR ); 957 } 958 959 for( final FilterRegistration reg : context.getFilterRegistrations().values() ) { 960 // 速度よりソースの見易さ 961 rtn.append( "<tr class=\"row_" ).append( no%2 ).append( "\" >" ) 962// .append( "<td>" ).append( String.valueOf( ++no ) ).append( "</td>" ) 963 .append( "<td class='S9'>" ).append( String.valueOf( ++no ) ).append( "</td>" ) // 7.0.4.0 (2019/05/31) 964 .append( "<td>Filter</td>" ) 965 .append( "<td>" ).append( reg.getName() ).append( "</td>" ) 966 .append( "<td>" ).append( reg.getClassName() ).append( "</td>" ) 967 .append( "<td>" ).append( reg.getUrlPatternMappings() ).append( "</td>" ) 968 .append( "</tr>" ).append( CR ); 969 } 970 971// rtn.append( TABLE_END ); 972// return rtn.toString(); 973 return rtn.append( TABLE_END ).toString(); 974 } 975 976 /** 977 * admin リンク情報を作成します。 978 * 簡易メソッドなので、国際化対応していません。 979 * 980 * @og.rev 3.5.4.1 (2003/12/01) 新規作成 981 * @og.rev 5.1.1.2 (2009/12/10) 画面IDを変更 982 * @og.rev 5.6.3.4 (2013/04/26) クイックリファレンス 画面を追加 983 * @og.rev 6.3.6.1 (2015/08/28) <table> 枠の指定と、</table> の static final String 化 984 * @og.rev 6.3.8.0 (2015/09/11) AccessStop を外部から制御できるように、コマンドと状態を受けるようにする。 985 * @og.rev 6.9.2.1 (2018/03/12) リンクが横に長くなってきたので、2段に折り返します。 986 * @og.rev 7.0.0.1 (2018/10/09) 一旦、[プラグイン情報],[タグリブ情報],[Servlet/Filter情報],[システム状況] を削除します。 987 * @og.rev 7.0.1.0 (2018/10/15) XHTML → HTML5 対応(空要素の、"/>" 止めを、">" に変更します)。 988 * @og.rev 7.1.0.0 (2020/01/20) logLink.jsp 、serviceRestart.jsp 追加。AccessStopのON/OFF追加 989 * @og.rev 7.1.0.0 (2020/01/27) static で定義しておきます。 990 * 991 * @return アドミンリンク情報 992 * @og.rtnNotNull 993 */ 994 private String getAdminLink() { 995//// final StringBuilder rtn = new StringBuilder( BUFFER_MIDDLE ) 996// return new StringBuilder( BUFFER_MIDDLE ) 997// .append( "<table><tr>" ) 998// .append( "<td width=\"10px\"/><td>[<a href=\"admin?COMMAND=infomation\" target=\"RESULT\" >状況表示</a>]</td>" ) 999// .append( "<td width=\"10px\"/><td>[<a href=\"admin?COMMAND=close\" target=\"RESULT\" >プール削除</a>]</td>" ) 1000// .append( "<td width=\"10px\"/><td>[<a href=\"admin?COMMAND=loginUser\" target=\"RESULT\" >ログインユーザー</a>]</td>" ) 1001// // .append( "<td width=\"10px\"/><td>[<a href=\"admin?COMMAND=plugin\" target=\"RESULT\" >プラグイン情報</a>]</td>" ) 1002// // .append( "<td width=\"10px\"/><td>[<a href=\"admin?COMMAND=taglib\" target=\"RESULT\" >タグリブ情報</a>]</td>" ) 1003// // .append( "<td width=\"10px\"/><td>[<a href=\"admin?COMMAND=registrationInfo\" target=\"RESULT\" >Servlet/Filter情報</a>]</td>" ) 1004// // .append( "</tr><tr>" ) 1005// .append( "<td width=\"10px\"/><td>[<a href=\"common/quickReference.html\" target=\"RESULT\" >クイックリファレンス</a>]</td>" ) // 5.6.3.4 (2013/04/26) 1006// .append( "<td width=\"10px\"/><td>[<a href=\"admin?COMMAND=systemResource\" target=\"RESULT\" >システムリソース</a>]</td>" ) // 6.3.8.0 (2015/09/11) 1007// .append( "<td width=\"10px\"/><td>アクセス制限[<a href=\"admin?COMMAND=AccessStop&stop=true\" target=\"RESULT\" >停止</a>]/" ) 1008// .append( "[<a href=\"admin?COMMAND=AccessStop&stop=false\" target=\"RESULT\" >開始</a>]</td>" ) 1009// .append( "<td width=\"10px\"/><td>[<a href=\"common/gamen/01_ADMIN/parameter.jsp?GAMENID=01_ADMIN\" target=\"RESULT\" >パラメータ</a>]</td>" ) 1010// // .append( "<td width=\"10px\"/><td>[<a href=\"common/gamen/01_ADMIN/systemInfo.jsp?GAMENID=01_ADMIN\" target=\"RESULT\" >システム状況</a>]</td>" ) 1011// .append( "</tr>" ).append( TABLE_END ) 1012// .toString(); 1013//// return rtn.toString(); 1014 1015 // 7.1.0.0 (2020/01/20) AccessStopのON/OFF追加 1016 final String accessStop = "true".equalsIgnoreCase( System.getProperty( "AccessStopFilter" ) ) 1017 ? ACCESS_STOP : "" ; 1018 1019 // 7.1.0.0 (2020/01/20) logLink.jsp 、serviceRestart.jsp 追加 1020 final String serviceRestart = "true".equalsIgnoreCase( HybsSystem.sys( "IS_SERVICE" ) ) 1021 ? SERVICE_RESTART : "" ; 1022 1023 // 7.1.0.0 (2020/01/27) static で定義しておきます。 1024 return new StringBuilder( BUFFER_MIDDLE ) 1025 .append( "<style> body { overflow-y: hidden; } </style>" ) // 1026 .append( "<table><tr>" ).append( CR ) 1027 .append( INFOMATION ) 1028 .append( CLOSE ) 1029 .append( LOGIN_USER ) 1030 .append( QUICK_REFERENCE ) 1031 .append( SYSTEM_RESOURCE ) 1032 .append( PARAMETER ) 1033 .append( LOGLINK ) 1034 .append( serviceRestart ) 1035 .append( "</tr>" ).append( CR ).append( "<tr><td /><td />" ).append( CR ) 1036 .append( PLUGIN ) 1037 .append( TAGLIB ) 1038 .append( REGISTRATION ) 1039 .append( SYSTEM_INFO ) 1040 .append( accessStop ) 1041 .append( "</tr>" ).append( TABLE_END ) 1042 .toString(); 1043 1044// return new StringBuilder( BUFFER_MIDDLE ) 1045// .append( "<table><tr>" ) 1046// .append( "<td> [<a href=\"admin?COMMAND=infomation\" target=\"RESULT\" >状況表示</a>]</td>" ) 1047// .append( "<td> [<a href=\"admin?COMMAND=close\" target=\"RESULT\" >プール削除</a>]</td>" ) 1048// .append( "<td> [<a href=\"admin?COMMAND=loginUser\" target=\"RESULT\" >ログインユーザー</a>]</td>" ) 1049// // .append( "<td> [<a href=\"admin?COMMAND=plugin\" target=\"RESULT\" >プラグイン情報</a>]</td>" ) 1050// // .append( "<td> [<a href=\"admin?COMMAND=taglib\" target=\"RESULT\" >タグリブ情報</a>]</td>" ) 1051// // .append( "<td> [<a href=\"admin?COMMAND=registrationInfo\" target=\"RESULT\" >Servlet/Filter情報</a>]</td>" ) 1052// .append( "<td> [<a href=\"common/quickReference.html\" target=\"RESULT\" >クイックリファレンス</a>]</td>" ) // 5.6.3.4 (2013/04/26) 1053// .append( "<td> [<a href=\"admin?COMMAND=systemResource\" target=\"RESULT\" >システムリソース</a>]</td>" ) // 6.3.8.0 (2015/09/11) 1054// .append( "<td> アクセス制限[<a href=\"admin?COMMAND=AccessStop&stop=true\" target=\"RESULT\" >停止</a>]/" ) 1055// .append( "[<a href=\"admin?COMMAND=AccessStop&stop=false\" target=\"RESULT\" >開始</a>]</td>" ) 1056// .append( "<td> [<a href=\"common/gamen/01_ADMIN/parameter.jsp?GAMENID=01_ADMIN\" target=\"RESULT\" >パラメータ</a>]</td>" ) 1057// // .append( "<td> [<a href=\"common/gamen/01_ADMIN/systemInfo.jsp?GAMENID=01_ADMIN\" target=\"RESULT\" >システム状況</a>]</td>" ) 1058// // 7.1.0.0 (2020/01/20) logLink.jsp 、serviceRestart.jsp 追加 1059// .append( "<td> [<a href=\"common/gamen/01_ADMIN/logLink.jsp\" target=\"RESULT\" >ログ</a>]</td>" ) 1060// .append( "<td> [<a href=\"common/gamen/01_ADMIN/serviceRestart.jsp\" target=\"RESULT\" >サービス再起動</a>]</td>" ) 1061// .append( "</tr>" ).append( TABLE_END ) 1062// .toString(); 1063 } 1064 1065 /** 1066 * DBTableModel から テーブルのタグ文字列を作成して返します。 1067 * 1068 * @og.rev 3.5.3.1 (2003/10/31) User情報のテーブルの設定を、システムリソース より行う。 1069 * @og.rev 5.2.2.0 (2010/11/01) SystemData 見直し漏れの対応。 1070 * 1071 * @return テーブルのタグ文字列 1072 * @og.rtnNotNull 1073 */ 1074 private static String getTableHeaderTag() { 1075 // 6.1.1.0 (2015/01/17) Attributesの連結記述 1076 return new Attributes() 1077 .set( "id" ,"viewTable" ) // 3.6.0.5 (2004/10/18) 1078 .set( "summary" ,"layout" ) // サマリー 1079 .getAttribute(); 1080 } 1081 1082 /** 1083 * userInfo 情報をセットします。 1084 * 現状、このメソッドではLANGのみ設定可能です。 1085 * (予約語以外のセットはuserInfoタグで行う) 1086 * 1087 * LANGではuserInfoを切り替えた後にユーザのGUIInfoを再ロードします。 1088 * 1089 * @og.rev 5.9.1.0 (2015/10/02) 新規作成 1090 * 1091 * @param req HttpServletRequestオブジェクト 1092 * @return 結果情報 1093 */ 1094 private String setUserinfo( final HttpServletRequest req ) { 1095 final HttpSession session = req.getSession(); 1096 final UserInfo userInfo = (UserInfo)(session.getAttribute( HybsSystem.USERINFO_KEY )); 1097 1098 final String infoLang = req.getParameter( "LANG" ); 1099 1100 String rtn = null ; 1101 if( userInfo != null && infoLang != null && infoLang.length() > 0) { 1102 userInfo.setLang( infoLang ); 1103 ResourceFactory.newInstance( userInfo.getLang() ).makeGUIInfos( userInfo ); 1104 rtn = "User language : " + infoLang; 1105 } 1106 1107 if( rtn == null || rtn.length() == 0 ) { 1108 rtn = "Error"; 1109 } 1110 1111 return rtn ; 1112 } 1113}