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