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 */ 016 package org.opengion.hayabusa.servlet; 017 018 import java.io.File; 019 import java.io.IOException; 020 import java.io.PrintWriter; 021 import java.lang.reflect.Field; 022 import java.net.URL; 023 import java.util.Enumeration; 024 import java.util.Map; 025 import java.util.jar.JarEntry; 026 import java.util.jar.JarFile; 027 028 import javax.servlet.ServletContext; 029 import javax.servlet.ServletException; 030 import javax.servlet.http.HttpServlet; 031 import javax.servlet.http.HttpServletRequest; 032 import javax.servlet.http.HttpServletResponse; 033 import javax.servlet.http.HttpSession; 034 035 import org.opengion.fukurou.db.ConnectionFactory; 036 import org.opengion.fukurou.util.Attributes; 037 import org.opengion.fukurou.util.HybsEntry; 038 import org.opengion.fukurou.util.StringUtil; 039 import org.opengion.fukurou.util.Closer ; // 5.5.2.6 (2012/05/25) 040 import org.opengion.hayabusa.common.BuildNumber; 041 import org.opengion.hayabusa.common.HybsSystem; 042 import org.opengion.hayabusa.common.SystemManager; 043 import org.opengion.hayabusa.common.SystemParameter; 044 import org.opengion.hayabusa.common.UserSummary; 045 046 /** 047 * サーバ?管?報を取得するAdminサーブレ?です? 048 * 049 * 引数(URL)に応じて、サーバ?の状態結果を返します? 050 * ?には、http://サーバ?:ポ??シス?ID/jsp/admin?COMMAND=コマン?の 051 * 形式?URL でアクセスします? 052 * 053 * ・COMMAND=infomation 054 * サーバ??? 055 * ???? = Windows 2000 Service Pack 4 056 * サーバ?? = HN50G5 ( 200.1.50.165 ) 057 * サーブレ? = Apache Tomcat/4.1.27-LE-jdk14 058 * REAL_PATH = H:\webapps\gf\ 059 * TOMCAT_WORK = H:\java\tomcat5.5.17\work\Catalina\localhost\ver4 060 * JDKバ?ジョン = Java HotSpot(TM) Server VM 1.4.2_02-b03 061 * JAVA_HOME = H:\java\jdk150\jre 062 * 063 * エンジンバ?ジョン 064 * バ?ジョンNo = 3.5.2.0 Release3 Builds (03291) 065 * 作?日? = 2003/10/18 17:50:35 066 * 067 * ログインユーザー 068 * ログイン人数 = 2 ?( 明細?? ) 069 * 070 * メモリ?? 071 * 空きメモリ = 15977 [KByte] 072 * 合計メモリ = 32448 [KByte] 073 * 使用? = 50 [?? 074 * 075 * ・COMMAND=close 076 * リソース??のキャ?ュを?てクリアします? 077 * 078 * ・COMMAND=loginUser 079 * 現在のログインユーザーの明細??を表示します? 080 * SORT=[JNAME,ID,ROLES,IPADDRESS,LOGINTIME] ソートキー 081 * DIREC=[true,false] true:??/false:降? 082 * 083 * ・COMMAND=plugin 084 * 現在のプラグインのバ?ジョン??を表示します? 085 * 086 * ・COMMAND=systemResource 087 * 現在のシス?リソースの設定情報を表示します? 088 * 089 * ・COMMAND=AccessStop 090 * アクセスストップフィルターの制御(停止、許可)を行います? 091 * 092 * @og.rev 3.5.3.0 (2003/10/27) Admin JSP ?Servlet化して、エンジンと共に供給します? 093 * @og.rev 4.0.0.0 (2005/08/31) プラグインのバ?ジョン??の表示機?を追? 094 * @og.group そ?他機? 095 * 096 * @version 4.0 097 * @author Kazuhiko Hasegawa 098 * @since JDK5.0, 099 */ 100 public final class HybsAdmin extends HttpServlet { 101 private static final long serialVersionUID = 4000 ; // 4.0.0 (2005/01/31) 102 103 private static final String CR = HybsSystem.CR ; 104 105 private static final String JSP = HybsSystem.sys( "JSP" ); // jspフォル??正規パス 106 107 private static final String HEADER = 108 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + CR + 109 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" + CR + 110 " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" + CR + 111 "<html xmlns=\"http://www.w3.org/1999/xhtml\" >" + CR + 112 "<head>" + CR + 113 " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />" + CR + 114 " <meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />" + CR + 115 " <link rel=\"stylesheet\" href=\"" + JSP + "/common/default.css\" type=\"text/css\" />" + CR + 116 " <link rel=\"stylesheet\" href=\"" + JSP + "/custom/custom.css\" type=\"text/css\" />" + CR + 117 " <title>Hybs Admin</title>" + CR + 118 "</head>" + CR; 119 120 // 3.5.3.1 (2003/10/31) User??の??ブルの設定を、シス?リソース より行う? 121 private static final String TABLE_HEADER = getTableHeaderTag() ; 122 123 private static final String OS_INFO = HybsSystem.sys( "OS_INFO" ); // Windows 7 Service Pack 1 124 private static final String SERVER_INFO = HybsSystem.sys( "SERVER_INFO" ); // 10374232-0004 ( 200.1.50.239 ) 125 private static final String SERVLET_INFO = HybsSystem.sys( "SERVLET_INFO" ); // Apache Tomcat/7.0.39 126 private static final String REAL_PATH = HybsSystem.sys( "REAL_PATH" ); // C:/opengion/uap/webapps/gf/ 127 private static final String TOMCAT_WORK = HybsSystem.sys( "TOMCAT_WORK" ); // C:/opengion/apps/jdk170u25/jre 128 private static final String JDK_INFO = HybsSystem.sys( "JDK_INFO" ); // Java HotSpot(TM) Server VM 23.25-b01 129 private static final String JAVA_HOME = HybsSystem.sys( "JAVA_HOME" ); // C:/opengion/apps/jdk170u25/jre 130 private static final String ENGINE_INFO = HybsSystem.sys( "ENGINE_INFO" ); // 5.6.6.0 Release5 Builds (2013182) 131 132 /** 133 * GET メソ?が呼ばれたときに実行します? 134 * 135 * @og.rev 3.5.3.1 (2003/10/31) 機?ごとにメソ?を呼び出すよ?修正します? 136 * @og.rev 3.5.4.1 (2003/12/01) getAdminLink() メソ?を追? 137 * 138 * @param req HttpServletRequestオブジェク? 139 * @param res HttpServletResponseオブジェク? 140 * 141 * @throws ServletException 142 * @throws IOException 143 */ 144 @Override 145 public void doGet( final HttpServletRequest req, final HttpServletResponse res) 146 throws ServletException, IOException { 147 148 res.setContentType( "text/html; charset=UTF-8" ); 149 PrintWriter out = res.getWriter(); 150 151 String command = req.getParameter( "COMMAND" ); 152 153 out.println( HEADER ); 154 out.println("<body>"); 155 156 out.print("<h2>"); 157 out.print( req.getServerName() ); 158 out.print( ":" ); 159 out.print( req.getServerPort() ); 160 out.print( req.getContextPath() ); 161 out.println("</h2>"); 162 163 if( "infomation".equalsIgnoreCase( command ) ) { 164 out.print( getInfomation() ); 165 } 166 else if( "close".equalsIgnoreCase( command ) ) { 167 out.print( getCloseMessage( req.getSession() ) ); 168 } 169 else if( "loginUser".equalsIgnoreCase( command ) ) { 170 String sort = req.getParameter( "sort" ); 171 String direc = req.getParameter( "direc" ); 172 boolean dir = (direc == null) ? true : Boolean.valueOf( direc ).booleanValue(); 173 out.print( getLoginUser(sort,dir) ); 174 } 175 else if( "plugin".equalsIgnoreCase( command ) ) { 176 out.print( getPlugInInfo() ); 177 } 178 else if( "taglib".equalsIgnoreCase( command ) ) { 179 out.print( getTaglibInfo() ); 180 } 181 else if( "systemResource".equalsIgnoreCase( command ) ) { 182 out.print( getSystemResource() ); 183 } 184 else if( "AccessStop".equalsIgnoreCase( command ) ) { 185 out.print( getAccessStop() ); 186 } 187 else { 188 out.print( getAdminLink() ); // 3.5.4.1 (2003/12/01) 追? 189 } 190 191 out.println("</body></html>"); 192 } 193 194 /** 195 * infomation ??を作?します? 196 * 197 * @og.rev 3.5.3.1 (2003/10/31) 機?ごとにメソ?を呼び出すよ?修正します? 198 * 199 * @return infomation?? 200 */ 201 private String getInfomation() { 202 // 4.0.0 (2005/01/31) ログイン数の取得方法?変更? 203 int loginCount = SystemManager.getRunningCount() ; 204 205 int freeMemory = (int)( Runtime.getRuntime().freeMemory()/1024 ) ; 206 int totalMemory = (int)( Runtime.getRuntime().totalMemory()/1024 ); 207 int useMemoryRatio = (((totalMemory - freeMemory) * 100 )/totalMemory) ; 208 209 StringBuilder rtn = new StringBuilder( HybsSystem.BUFFER_MIDDLE ); 210 211 rtn.append( "<table border = \"0px\" >" ).append( CR ); 212 tableTr1( rtn,"サーバ???" ); 213 tableTr( rtn,"????" , OS_INFO ); 214 tableTr( rtn,"サーバ?? , SERVER_INFO ); 215 tableTr( rtn,"サーブレ?" , SERVLET_INFO ); 216 tableTr( rtn,"REAL_PATH" , REAL_PATH ); 217 tableTr( rtn,"TOMCAT_WORK" , TOMCAT_WORK ); 218 tableTr( rtn,"JDKバ?ジョン", JDK_INFO ); 219 tableTr( rtn,"JAVA_HOME" , JAVA_HOME ); 220 221 tableTr1( rtn,"エンジンバ?ジョン" ); 222 tableTr( rtn,"バ?ジョンNo" , ENGINE_INFO ); 223 tableTr( rtn,"作?日? , BuildNumber.TIMESTAMP ); 224 225 tableTr( rtn,"ログインユーザー" ); 226 tableTr( rtn,"ログイン人数" , String.valueOf( loginCount )," ?","( <a href=\"admin?COMMAND=loginUser\">明細??</a> )" ); 227 228 tableTr1( rtn,"メモリ??" ); 229 tableTr( rtn,"空きメモリ" , String.valueOf( freeMemory ) , " [KByte]" ); 230 tableTr( rtn,"合計メモリ" , String.valueOf( totalMemory ) , " [KByte]" ); 231 tableTr( rtn,"使用? , String.valueOf( useMemoryRatio ) , " [??" ); 232 233 // rtn.append( " <tr><td colspan = \"4\">サーバ???</td></tr>" ).append( CR ); 234 // rtn.append( " <tr><td></td><td>????</td><td>=</td><td>" ).append( OS_INFO ).append( "</td></tr>" ).append( CR ); 235 // rtn.append( " <tr><td></td><td>サーバ??/td><td>=</td><td>" ).append( SERVER_INFO ).append( "</td></tr>" ).append( CR ); 236 // rtn.append( " <tr><td></td><td>サーブレ?</td><td>=</td><td>" ).append( SERVLET_INFO ).append( "</td></tr>" ).append( CR ); 237 // rtn.append( " <tr><td></td><td>REAL_PATH</td><td>=</td><td>" ).append( REAL_PATH ).append( "</td></tr>" ).append( CR ); 238 // rtn.append( " <tr><td></td><td>TOMCAT_WORK</td><td>=</td><td>" ).append( TOMCAT_WORK ).append( "</td></tr>" ).append( CR ); 239 // rtn.append( " <tr><td></td><td>JDKバ?ジョン</td><td>=</td><td>" ).append( JDK_INFO ).append( "</td></tr>" ).append( CR ); 240 // rtn.append( " <tr><td></td><td>JAVA_HOME</td><td>=</td><td>" ).append( JAVA_HOME ).append( "</td></tr>" ).append( CR ); 241 // rtn.append( " <th><td></td><td colspan = \"2\"></td></th>" ).append( CR ); 242 // rtn.append( " <tr><td colspan = \"4\">エンジンバ?ジョン</td></tr>" ).append( CR ); 243 // rtn.append( " <tr><td></td><td>バ?ジョンNo</td><td>=</td><td>" ).append( ENGINE_INFO ).append( "</td></tr>" ).append( CR ); 244 // rtn.append( " <tr><td></td><td>作?日?/td><td>=</td><td>" ).append( BuildNumber.TIMESTAMP ).append( "</td></tr>" ).append( CR ); 245 // rtn.append( " <th><td></td><td colspan = \"2\"></td></th>" ).append( CR ); 246 // rtn.append( " <tr><td colspan = \"4\">ログインユーザー</td></tr>" ).append( CR ); 247 // rtn.append( " <tr><td></td><td>ログイン人数 </td><td>=</td><td>" ).append( loginCount ).append( " ?" ); 248 // rtn.append( "( <a href=\"admin?COMMAND=loginUser\">明細??</a> )</td></tr>" ).append( CR ); 249 // rtn.append( " <tr><td colspan = \"4\">メモリ??</td></tr>" ).append( CR ); 250 // rtn.append( " <tr><td></td><td>空きメモリ</td><td>=</td><td>" ).append( freeMemory ).append( " [KByte]</td></tr>" ).append( CR ); 251 // rtn.append( " <tr><td></td><td>合計メモリ</td><td>=</td><td>" ).append( totalMemory ).append( " [KByte]</td></tr>" ).append( CR ); 252 // rtn.append( " <tr><td></td><td>使用?/td><td>=</td><td>" ).append( useMemoryRatio ).append( " [??</td></tr>" ).append( CR ); 253 rtn.append( "</table>" ).append( CR ); 254 rtn.append( CR ); 255 rtn.append( "<table width=\"50%\" frame=\"box\" border = \"1px\" cellspacing=\"0px\" cellpadding=\"0px\" >" ).append( CR ); 256 // rtn.append( " <tr><td width=\"" ).append( useMemoryRatio ).append( "%\" bgcolor=\"red\" >" ).append( CR ); 257 // rtn.append( " <img width=\"100%\" height=\"10px\" src=\"" ).append( JSP ).append( "/image/space.gif\" alt=\"" ).append( useMemoryRatio ).append( "%\"></td>" ).append( CR ); 258 // rtn.append( " <td></td>" ).append( CR ); 259 // rtn.append( " </tr>" ).append( CR ); 260 rtn.append( " <tr><td align=\"center\" width=\"" ).append( useMemoryRatio ).append( "%\" bgcolor=\"red\" >" ).append( CR ); 261 rtn.append( useMemoryRatio ).append( "%</td>" ).append( CR ); 262 rtn.append( " <td align=\"center\">" ).append( 100-useMemoryRatio ).append( "%</td>" ).append( CR ); 263 rtn.append( " </tr>" ).append( CR ); 264 rtn.append( "</table>" ).append( CR ); 265 rtn.append( "<hr />" ).append( CR ); 266 rtn.append( "<pre>" ).append( CR ); 267 rtn.append( ConnectionFactory.information() ).append( CR ); 268 rtn.append( "</pre>" ).append( CR ); 269 270 return rtn.toString(); 271 } 272 273 /** 274 * infomation ??を作?します? 275 * 276 * @og.rev 5.6.6.0 (2013/07/05) </td></tr>漏れ追? 277 * 278 * @param buf ??登録用のStringBuilder(出力と同じオブジェク? 279 * @param key キー 280 * 281 * @return infomation?? 282 */ 283 private StringBuilder tableTr1( final StringBuilder buf, final String key ) { 284 // buf.append( "<tr><td colspan = \"4\">" ).append( key ).append( CR ); 285 buf.append( "<tr><td colspan=\"4\"><b>" ).append( key ).append( "</b></td></tr>" ).append( CR ); // td,tr 漏れ追? 286 return buf ; 287 } 288 289 /** 290 * infomation ??を作?します? 291 * 292 * @og.rev 5.6.6.0 (2013/07/05) ??の td に、?角スペ?ス?? 追? 293 * 294 * @param buf ??登録用のStringBuilder(出力と同じオブジェク? 295 * @param key キー 296 * @param val 値の可変長引数 297 * 298 * @return infomation?? 299 */ 300 private StringBuilder tableTr( final StringBuilder buf, final String key, final String... val ) { 301 // buf.append( "\t<tr><td></td><td>" ).append( key ).append( "</td><td>=</td><td>" ); 302 buf.append( "<tr><td width=\"20px\">?/td><td>" ).append( key ).append( "</td><td>=</td><td>" ); // 段を作?する為に、width??追? 303 for( int i=0; i<val.length; i++ ) { 304 buf.append( val[i] ); 305 } 306 buf.append( "</td></tr>" ).append( CR ); 307 return buf ; 308 } 309 310 /** 311 * close ??を作?します? 312 * 313 * @og.rev 3.5.3.1 (2003/10/31) 機?ごとにメソ?を呼び出すよ?修正します? 314 * @og.rev 3.6.0.0 (2004/09/17) CalendarFactory.clear() を追?ます? 315 * @og.rev 4.0.0.0 (2005/01/31) Cleanable インターフェースによる初期化?? 316 * @og.rev 4.1.0.2 (2008/01/29) UserInfoをsessionから消去する(?定対? 317 * @og.rev 5.6.6.0 (2013/07/05) UserSummary の削除処??、SystemManager から行う? 318 * 319 * @param session HttpSessionオブジェク? 320 * 321 * @return close?? 322 */ 323 private String getCloseMessage( final HttpSession session ) { 324 325 // 4.0.0 (2005/01/31) Cleanable インターフェースによる初期化?? 326 SystemManager.allClear( false ) ; 327 328 ServletContext context = session.getServletContext(); 329 Map<String,String> param = SystemParameter.makeSystemParameter( context ); 330 HybsSystem.setInitialData( param ); // 4.0.0 (2005/01/31) 331 332 // 5.6.6.0 (2013/07/05) UserSummary の削除処??、SystemManager から行う? 333 SystemManager.removeSession( session ) ; 334 335 // UserSummary userInfo = (UserSummary)session.getAttribute( HybsSystem.USERINFO_KEY ); 336 //// if( userInfo != null ) { userInfo.clear(); } 337 // if( userInfo != null ) { // 4.1.0.2 (2008/01/29) 338 // userInfo.clear(); 339 // session.removeAttribute( HybsSystem.USERINFO_KEY ); 340 // } 341 342 String rtn = "<pre>" 343 + "キャ?ュ??をクリアーしました? 344 + CR 345 + "ユーザー??の初期化に関しては、ブラウザを閉じて、?ログインが?です?" 346 + CR 347 + ConnectionFactory.information() 348 + "</pre>" ; 349 return rtn ; 350 } 351 352 // 5.6.6.0 (2013/07/05) getLoginUser( String,boolean ) で、指定するキーを?列で持っておきます? 353 // キーは、SystemManager.getRunningUserSummary 処??で大?化されるため?こ?配?は、表示用と兼用します? 354 private static final String[] USER_KEYS = new String[] { "ID","Jname","Roles","IPAddress","LoginTime","LastAccess","LastGamenNm" }; 355 356 /** 357 * loginUser ??を作?します? 358 * 359 * @og.rev 3.5.3.1 (2003/10/31) 機?ごとにメソ?を呼び出すよ?修正します? 360 * @og.rev 3.8.5.3 (2006/08/07) ユーザー??をソートするため?キー??を追? 361 * @og.rev 3.8.7.0 (2006/12/15) USER.LASTACCESS??を追?ます? 362 * @og.rev 4.0.0.0 (2005/01/31) DBColumn の 属?(CLS_NM)から、DBTYPEに変更 363 * @og.rev 4.4.0.1 (2009/08/08) ?ログイン画面名称を追? 364 * @og.rev 5.6.6.0 (2013/07/05) table作?処?、変更します? 365 * 366 * @param sort ソートするキー?を指? 367 * @param direc ソートする方?[true:??/false:降?] 368 * 369 * @return loginUser?? 370 */ 371 private String getLoginUser( final String sort,final boolean direc ) { 372 // 4.0.0 (2005/01/31) ログイン数の取得方法?変更? 373 int loginCount = SystemManager.getRunningCount() ; 374 375 // 4.0.0 (2005/01/31) 376 UserSummary[] userInfos = SystemManager.getRunningUserSummary( sort,direc ); 377 378 StringBuilder rtn = new StringBuilder( HybsSystem.BUFFER_MIDDLE ); 379 380 rtn.append( "現在 " ).append( loginCount ).append( " 名?方がログイン中です?" ); 381 rtn.append( CR ); 382 383 rtn.append( "<table " ).append( TABLE_HEADER ).append( " >" ).append( CR ); 384 rtn.append( " <thead><tr><th>No</th>" ); 385 386 // 5.6.6.0 (2013/07/05) table作?処?、変更します? 387 for( String sortKey : USER_KEYS ) { 388 rtn.append( " <th><a href=\"?COMMAND=loginUser&sort=" ).append( sortKey ) 389 .append( "&direc=" ).append( !direc ) 390 .append( "\">" ).append( sortKey ).append( "</a></th>" ); 391 } 392 393 // rtn.append( " <th><a href=\"?COMMAND=loginUser&sort=ID&direc=" ).append( !direc ); 394 // rtn.append( "\">UserID</a></th>" ); 395 // rtn.append( " <th><a href=\"?COMMAND=loginUser&sort=JNAME&direc=" ).append( !direc ); 396 // rtn.append( "\">Jname</a></th>" ); 397 // rtn.append( " <th><a href=\"?COMMAND=loginUser&sort=ROLES&direc=" ).append( !direc ); 398 // rtn.append( "\">Roles</th>" ); 399 // rtn.append( " <th><a href=\"?COMMAND=loginUser&sort=IPADDRESS&direc=" ).append( !direc ); 400 // rtn.append( "\">IPAddress</a></th>" ); 401 // rtn.append( " <th><a href=\"?COMMAND=loginUser&sort=LOGINTIME&direc=" ).append( !direc ); 402 // rtn.append( "\">LoginTime</a></th>" ); 403 // rtn.append( " <th><a href=\"?COMMAND=loginUser&sort=LASTACCESS&direc=" ).append( !direc ); 404 // rtn.append( "\">LastAccess</a></th>" ); 405 // rtn.append( " <th><a href=\"?COMMAND=loginUser&sort=LASTGAMENNM&direc=").append( !direc ); // 4.4.0.1 (2009/08/08) 406 // rtn.append( "\">LastGamenName</a></th>" ); 407 rtn.append( " </tr></thead>" ).append( CR ); 408 rtn.append( " <colgroup class=\"S9\" />" ).append( CR ); 409 rtn.append( " <colgroup class=\"X\" span=\"6\" />" ).append( CR ); 410 rtn.append( CR ); 411 412 for( int i=0; i<userInfos.length; i++ ) { 413 UserSummary userInfo = userInfos[i] ; 414 rtn.append( " <tr class=\"row_" ).append( i%2 ).append( "\" >" ).append( CR ); 415 rtn.append( " <td>" ).append( String.valueOf( i+1 ) ).append( "</td>" ).append( CR ); 416 rtn.append( " <td>" ).append( userInfo.getUserID() ).append( "</td>" ).append( CR ); 417 rtn.append( " <td>" ).append( userInfo.getJname() ).append( "</td>" ).append( CR ); 418 rtn.append( " <td>" ).append( userInfo.getRoles() ).append( "</td>" ).append( CR ); 419 rtn.append( " <td>" ).append( userInfo.getIPAddress() ).append( "</td>" ).append( CR ); 420 rtn.append( " <td>" ).append( HybsSystem.getDate( userInfo.getLoginTime() ) ).append( "</td>" ).append( CR ); 421 rtn.append( " <td>" ).append( userInfo.getAttribute( "LASTACCESS") ).append( "</td>" ).append( CR ); 422 rtn.append( " <td>" ).append( StringUtil.nval( userInfo.getAttribute( "LASTGAMENNM"), "" ) ).append( "</td>" ).append( CR ); // 4.4.0.1 (2009/08/08) 423 rtn.append( " </tr>" ).append( CR ); 424 } 425 rtn.append( "</table>" ).append( CR ); 426 427 return rtn.toString() ; 428 } 429 430 /** 431 * PlugIn ??を作?します? 432 * 433 * @og.rev 4.0.0.0 (2005/08/31) 新規作? 434 * @og.rev 5.6.6.0 (2013/07/05) "DBConstValue","Daemon","JspCreate" を?追?ます? 435 * 436 * @return PlugIn?? 437 */ 438 private String getPlugInInfo() { 439 440 String[] pluginType = new String[] { 441 "Query","Renderer","Editor","DBType","ViewForm", 442 "TableReader","TableWriter","TableFilter","ChartWriter","CalendarQuery", 443 "DBConstValue","Daemon","JspCreate" // 5.6.6.0 (2013/07/05) 追? 444 } ; 445 446 ClassInfo info = new ClassInfo(); 447 448 for( int j=0; j<pluginType.length; j++ ) { 449 String type = pluginType[j] ; 450 HybsEntry[] names = HybsSystem.sysEntry( type + "_" ); 451 for( int i=0; i<names.length; i++ ) { 452 String key = names[i].getKey().substring( type.length()+1 ); 453 String clsName = names[i].getValue(); 454 info.addLine( type,key,clsName ); 455 } 456 } 457 return info.getClassInfoData() ; 458 } 459 460 /** 461 * Taglib ??を作?します? 462 * 463 * @og.rev 4.0.0.0 (2006/01/31) 新規作? 464 * @og.rev 5.3.6.0 (2011/06/01) Taglib クラス名?求め方を変更します?(jar版?み) 465 * @og.rev 5.5.2.6 (2012/05/25) JarFile を?Closer#zipClose( ZipFile ) メソ?を利用して、close します? 466 * 467 * @return Taglib?? 468 */ 469 private String getTaglibInfo() { 470 ClassInfo info = new ClassInfo(); 471 472 // 5.5.2.6 (2012/05/25) findbugs対? 473 JarFile jarFile = null; 474 try { 475 ClassLoader loader = Thread.currentThread().getContextClassLoader(); 476 Enumeration<URL> enume = loader.getResources( "org/opengion/hayabusa/taglib/" ); // 4.3.3.6 (2008/11/15) Generics警告対? 477 while( enume.hasMoreElements() ) { 478 URL url = enume.nextElement(); // 4.3.3.6 (2008/11/15) Generics警告対? 479 // jar:file:/実ディレクトリ また?、file:/実ディレクトリ 480 String dir = url.getFile(); 481 if( "jar".equals( url.getProtocol() ) ) { 482 // dir = file:/G:/webapps/gf/WEB-INF/lib/hayabusa4.0.0.jar!/org/opengion/hayabusa/taglib 形式です? 483 String jar = dir.substring(dir.indexOf( ':' )+1,dir.lastIndexOf( '!' )); 484 // jar = /G:/webapps/gf/WEB-INF/lib/hayabusa4.0.0.jar 形式に?出します? 485 // JarFile jarFile = new JarFile( jar ); 486 jarFile = new JarFile( jar ); 487 Enumeration<JarEntry> en = jarFile.entries() ; // 4.3.3.6 (2008/11/15) Generics警告対? 488 while( en.hasMoreElements() ) { 489 JarEntry ent = en.nextElement(); // 4.3.3.6 (2008/11/15) Generics警告対? 490 String file = ent.getName(); 491 if( ! ent.isDirectory() && file.endsWith( "Tag.class" ) ) { 492 String type = "Taglib"; 493 // 5.3.6.0 (2011/06/01) Taglib クラス名?求め方を変更します?(jar版?み) 494 // String key = file.substring( 0,file.length()-6 ); 495 String key = file.substring( file.lastIndexOf( '/' )+1,file.length()-6 ); // -6 は?class ? 496 // String clsName = "org.opengion.hayabusa.taglib." + key ; 497 String clsName = file.replace( '/','.' ).substring( 0,file.length()-6 ); 498 info.addLine( type,key,clsName ); 499 } 500 } 501 Closer.zipClose( jarFile ); // 5.5.2.6 (2012/05/25) findbugs対? 502 jarFile = null; // 正常終?に、close() が2回呼ばれるのを防ぐため? 503 } 504 else { 505 // dir = /G:/webapps/gf/WEB-INF/classes/org/opengion/hayabusa/taglib/ 形式です? 506 File fileObj = new File( dir ); 507 File[] list = fileObj.listFiles(); 508 for( int i=0; i<list.length; i++ ) { 509 String file = list[i].getName() ; 510 if( list[i].isFile() && file.endsWith( "Tag.class" ) ) { 511 String type = "Taglib"; 512 String key = file.substring( 0,file.length()-6 ); 513 String clsName = "org.opengion.hayabusa.taglib." + key ; 514 info.addLine( type,key,clsName ); 515 } 516 } 517 } 518 } 519 } 520 catch( IOException ex ) { 521 String errMsg = "taglibファイル読み取りストリー?失敗しました? 522 + CR + ex.getMessage(); 523 throw new RuntimeException( errMsg,ex ); 524 } 525 finally { 526 Closer.zipClose( jarFile ); // 5.5.2.6 (2012/05/25) findbugs対? 527 } 528 529 return info.getClassInfoData() ; 530 } 531 532 /** 533 * クラス??を表示するための??タを管?ます? 534 * ここでは、引数に渡された???Classify)、名称(Key Name)、クラス?Class Name)? 535 * バ?ジョン(Version)??をテーブル形式で表示します? 536 * バ?ジョン??は、クラス名から?インスタンスを作?して、private static final String VERSION 537 * フィールド?値を読み取ります? 538 * 539 * @og.rev 4.0.0.0 (2006/01/31) 新規作? 540 */ 541 private static final class ClassInfo { 542 private final StringBuilder rtn = new StringBuilder( HybsSystem.BUFFER_MIDDLE ); 543 private int cnt = 0; 544 545 /** 546 * コンストラクター 547 * 548 * @og.rev 4.0.0.0 (2006/01/31) 新規作? 549 */ 550 public ClassInfo() { 551 rtn.append( "<table " ).append( TABLE_HEADER ).append( " >" ).append( CR ); 552 rtn.append( " <thead><tr><th>No</th><th>Classify</th><th>Key Name</th><th>Class Name</th><th>Version</th></tr></thead>" ).append( CR ); 553 rtn.append( " <colgroup class=\"S9\" />" ).append( CR ); 554 rtn.append( " <colgroup class=\"X\" />" ).append( CR ); 555 rtn.append( " <colgroup class=\"X\" />" ).append( CR ); 556 rtn.append( " <colgroup class=\"X\" />" ).append( CR ); 557 rtn.append( " <colgroup class=\"X\" />" ).append( CR ); 558 rtn.append( " <colgroup class=\"X\" />" ).append( CR ); 559 rtn.append( CR ); 560 } 561 562 /** 563 * ??ブル表示用の??タを追?ます? 564 * 565 * @og.rev 4.0.0.0 (2006/01/31) 新規作? 566 * 567 * @param type タイプ属? 568 * @param key キー属? 569 * @param clsName クラス?こ?クラス名からインスタンス化します?) 570 */ 571 public void addLine( final String type, final String key, final String clsName ) { 572 String version = getFieldValue( clsName ); 573 574 boolean isCustom = ( version.compareTo( BuildNumber.VERSION_NO ) > 0 ) || 575 version.indexOf( "Pache" ) >= 0 || 576 version.indexOf( "Nightly" ) >= 0 ; 577 578 String trType = ( isCustom ) ? "warning" : String.valueOf( cnt%2 ); 579 580 rtn.append( " <tr class=\"row_" ).append( trType ).append( "\" >" ).append( CR ); 581 rtn.append( " <td>" ).append( cnt++ ).append( "</td>" ).append( CR ); 582 rtn.append( " <td>" ).append( type ).append( "</td>" ).append( CR ); 583 rtn.append( " <td>" ).append( key ).append( "</td>" ).append( CR ); 584 rtn.append( " <td>" ).append( clsName ).append( "</td>" ).append( CR ); 585 rtn.append( " <td>" ).append( version ).append( "</td>" ).append( CR ); 586 rtn.append( " </tr>" ).append( CR ); 587 } 588 589 /** 590 * すべての?の??タを文字?化して返します? 591 * 592 * @og.rev 4.0.0.0 (2006/01/31) 新規作? 593 * 594 * @return 作?されたテーブル??タ 595 */ 596 public String getClassInfoData() { 597 rtn.append( "</table>" ).append( CR ); 598 return rtn.toString() ; 599 } 600 601 /** 602 * ??オブジェクト? VERSION staticフィールド?値を取得します? 603 * 604 * @og.rev 4.0.0.0 (2005/08/31) 新規作? 605 * 606 * @param clsName ??クラスを表す名称 607 * @return VERSION staticフィールド?値(エラー時?、そのメ?ージ) 608 */ 609 private String getFieldValue( final String clsName ) { 610 String rtn ; 611 try { 612 Object obj = HybsSystem.newInstance( clsName ); 613 Field fld = obj.getClass().getDeclaredField( "VERSION" ) ; 614 // privateフィールド?取得には、accessibleフラグ?trueにする?があります? 615 fld.setAccessible( true ); 616 617 rtn = (String)fld.get( null ); 618 } 619 catch( Throwable ex ) { 620 rtn = ex.getMessage(); 621 } 622 return rtn ; 623 } 624 } 625 626 /** 627 * systemResource ??を作?します? 628 * 629 * @og.rev 3.5.3.1 (2003/10/31) 機?ごとにメソ?を呼び出すよ?修正します? 630 * @og.rev 4.0.0.0 (2005/01/31) DBColumn の 属?(CLS_NM)から、DBTYPEに変更 631 * 632 * @return systemResource?? 633 */ 634 private String getSystemResource() { 635 StringBuilder rtn = new StringBuilder( HybsSystem.BUFFER_MIDDLE ); 636 637 rtn.append( "<table " ).append( TABLE_HEADER ).append( " >" ).append( CR ); 638 rtn.append( " <thead><tr><th>No</th><th>Key</th><th>Value</th></tr></thead>" ).append( CR ); 639 rtn.append( " <colgroup class=\"S9\" />" ).append( CR ); 640 rtn.append( " <colgroup class=\"X\" span=\"2\" />" ).append( CR ); 641 rtn.append( CR ); 642 643 String[][] str = HybsSystem.getSystemResourceData(); 644 for( int i=0; i<str[0].length; i++ ) { 645 rtn.append( " <tr class=\"row_" ).append( i%2 ).append( "\" >" ).append( CR ); 646 rtn.append( " <td>" ).append( String.valueOf( i+1 ) ).append( "</td>" ).append( CR ); 647 rtn.append( " <td>" ).append( str[0][i] ).append( "</td>" ).append( CR ); 648 rtn.append( " <td>" ).append( str[1][i] ).append( "</td>" ).append( CR ); 649 rtn.append( " </tr>" ).append( CR ); 650 } 651 rtn.append( "</table>" ).append( CR ); 652 653 return rtn.toString(); 654 } 655 656 /** 657 * AccessStop ??を作?します? 658 * 659 * @og.rev 3.5.3.1 (2003/10/31) 機?ごとにメソ?を呼び出すよ?修正します? 660 * @og.rev 4.0.0.0 (2007/11/29) AccessStopFilter#getStopFilter() ?isStopFilter() に変更 661 * 662 * @return AccessStop?? 663 */ 664 private String getAccessStop() { 665 666 // boolean flag = org.opengion.hayabusa.filter.AccessStopFilter.getStopFilter(); 667 boolean flag = org.opengion.hayabusa.filter.AccessStopFilter.isStopFilter(); 668 flag = !flag ; 669 670 final String rtn ; 671 if( flag ) { 672 rtn = "Webアプリケーションのサービスを停止します?"; 673 } 674 else { 675 rtn = "Webアプリケーションのサービスを開始します?"; 676 } 677 org.opengion.hayabusa.filter.AccessStopFilter.setStopFilter( flag ); 678 679 return rtn ; 680 } 681 682 /** 683 * admin リンク??を作?します? 684 * 簡易メソ?なので、国際化対応して?せん? 685 * 686 * @og.rev 3.5.4.1 (2003/12/01) 新規作? 687 * @og.rev 5.1.1.2 (2009/12/10) 画面IDを変更 688 * @og.rev 5.6.3.4 (2013/04/26) ?????ファ?ンス 画面を追? 689 * 690 * @return アドミンリンク?? 691 */ 692 private String getAdminLink() { 693 StringBuilder rtn = new StringBuilder( HybsSystem.BUFFER_MIDDLE ); 694 695 rtn.append( "<table><tr>" ).append( CR ); 696 rtn.append( "<td width=\"10px\"/>" ).append( CR ); 697 rtn.append( "<td>[<a href=\"admin?COMMAND=infomation\" target=\"RESULT\" >状況表示</a>]</td>" ).append( CR ); 698 rtn.append( "<td width=\"10px\"/>" ).append( CR ); 699 rtn.append( "<td>[<a href=\"admin?COMMAND=close\" target=\"RESULT\" >?゚ー?削除</a>]</td>" ).append( CR ); 700 rtn.append( "<td width=\"10px\"/><td>" ).append( CR ); 701 rtn.append( "[<a href=\"admin?COMMAND=loginUser\" target=\"RESULT\" >?ク?イ?ユー??ー</a>]</td>" ).append( CR ); 702 rtn.append( "<td width=\"10px\"/><td>" ).append( CR ); 703 rtn.append( "[<a href=\"admin?COMMAND=plugin\" target=\"RESULT\" >?゚ラク?イ?情報</a>]</td>" ).append( CR ); 704 rtn.append( "<td width=\"10px\"/><td>" ).append( CR ); 705 rtn.append( "[<a href=\"admin?COMMAND=taglib\" target=\"RESULT\" >???リブ情報</a>]</td>" ).append( CR ); 706 rtn.append( "<td width=\"10px\"/><td>" ).append( CR ); 707 rtn.append( "[<a href=\"common/quickReference.html\" target=\"RESULT\" >?????ファ?ンス</a>]</td>" ).append( CR ); // 5.6.3.4 (2013/04/26) 708 rtn.append( "<td width=\"10px\"/><td>" ).append( CR ); 709 rtn.append( "[<a href=\"admin?COMMAND=systemResource\" target=\"RESULT\" >????リソ??</a>]</td>" ).append( CR ); 710 rtn.append( "<td width=\"10px\"/><td>" ).append( CR ); 711 // rtn.append( "[<a href=\"common/gamen/01_ADMIN/parameter.jsp?GAMENID=ADMIN\" target=\"RESULT\" >Parameter</a>]</td>" ).append( CR ); 712 rtn.append( "[<a href=\"common/gamen/01_ADMIN/parameter.jsp?GAMENID=01_ADMIN\" target=\"RESULT\" >Parameter</a>]</td>" ).append( CR ); 713 rtn.append( "</tr></table>" ).append( CR ); 714 715 return rtn.toString(); 716 } 717 718 /** 719 * DBTableModel から ??ブルのタグ??を作?して返します? 720 * 721 * @og.rev 3.5.3.1 (2003/10/31) User??の??ブルの設定を、シス?リソース より行う? 722 * @og.rev 5.2.2.0 (2010/11/01) SystemData 見直し漏れの対応? 723 * 724 * @return ??ブルのタグ?? 725 */ 726 private static String getTableHeaderTag() { 727 Attributes attri = new Attributes(); 728 attri.set( "id" ,"viewTable" ); // 3.6.0.5 (2004/10/18) 729 attri.set( "summary" ,"layout" ); // サマリー 730 731 // // 4.0.0 (2005/08/31) ??ブル表示の CSSファイル利用の有無 732 // boolean useCSSfile = HybsSystem.sysBool( "USE_HTML_TABLE_CSS" ) ; 733 // 734 // if( ! useCSSfile ) { 735 // attri.set( "summary" ,"layout" ); // サマリー 736 // attri.set( "border" ,HybsSystem.sys( "HTML_BORDER" ) ) ; // 外枠の太? 737 // attri.set( "width" ,HybsSystem.sys( "HTML_WIDTH" ) ) ; // 表の大きさ(?ピクセルまた?,?? 738 // attri.set( "frame" ,HybsSystem.sys( "HTML_FRAME" ) ) ; // 外枠の表示形? void,above,below,lhs,rhs,hsides,vsides,box,border 739 // attri.set( "rules" ,HybsSystem.sys( "HTML_RULES" ) ) ; // セルを区?線?形?none,rows,cols,groups,all 740 // attri.set( "cellspacing" ,HybsSystem.sys( "HTML_CELLSPACING" ) ); // セルの間隔 741 // attri.set( "cellpadding" ,HybsSystem.sys( "HTML_CELLPADDING" ) ); // セル??マ?ジン 742 // } 743 744 return attri.getAttribute(); 745 } 746 }