001 package railo.runtime.tag; 002 003 import java.io.IOException; 004 import java.net.MalformedURLException; 005 import java.net.URL; 006 import java.security.cert.X509Certificate; 007 import java.sql.Connection; 008 import java.sql.Driver; 009 import java.sql.SQLException; 010 import java.util.ArrayList; 011 import java.util.Arrays; 012 import java.util.Enumeration; 013 import java.util.Iterator; 014 import java.util.List; 015 import java.util.Locale; 016 import java.util.Map; 017 import java.util.Map.Entry; 018 import java.util.TimeZone; 019 020 import javax.servlet.ServletConfig; 021 import javax.servlet.jsp.tagext.Tag; 022 023 import org.xml.sax.SAXException; 024 025 import railo.print; 026 import railo.commons.collections.HashTable; 027 import railo.commons.db.DBUtil; 028 import railo.commons.digest.MD5; 029 import railo.commons.io.CompressUtil; 030 import railo.commons.io.IOUtil; 031 import railo.commons.io.SystemUtil; 032 import railo.commons.io.cache.Cache; 033 import railo.commons.io.cache.Cache2; 034 import railo.commons.io.log.Log; 035 import railo.commons.io.log.LogAndSource; 036 import railo.commons.io.log.LogResource; 037 import railo.commons.io.log.LogUtil; 038 import railo.commons.io.res.Resource; 039 import railo.commons.io.res.filter.DirectoryResourceFilter; 040 import railo.commons.io.res.filter.ExtensionResourceFilter; 041 import railo.commons.io.res.filter.LogResourceFilter; 042 import railo.commons.io.res.filter.NotResourceFilter; 043 import railo.commons.io.res.filter.OrResourceFilter; 044 import railo.commons.io.res.filter.ResourceFilter; 045 import railo.commons.io.res.util.ResourceUtil; 046 import railo.commons.lang.ClassException; 047 import railo.commons.lang.ClassUtil; 048 import railo.commons.lang.ExceptionUtil; 049 import railo.commons.lang.IDGenerator; 050 import railo.commons.lang.StringUtil; 051 import railo.commons.net.JarLoader; 052 import railo.commons.surveillance.HeapDumper; 053 import railo.runtime.CFMLFactory; 054 import railo.runtime.CFMLFactoryImpl; 055 import railo.runtime.Mapping; 056 import railo.runtime.MappingImpl; 057 import railo.runtime.PageContextImpl; 058 import railo.runtime.PageSource; 059 import railo.runtime.PageSourceImpl; 060 import railo.runtime.cache.CacheConnection; 061 import railo.runtime.cfx.customtag.CFXTagClass; 062 import railo.runtime.cfx.customtag.CPPCFXTagClass; 063 import railo.runtime.cfx.customtag.JavaCFXTagClass; 064 import railo.runtime.config.AdminSync; 065 import railo.runtime.config.Config; 066 import railo.runtime.config.ConfigImpl; 067 import railo.runtime.config.ConfigServer; 068 import railo.runtime.config.ConfigServerImpl; 069 import railo.runtime.config.ConfigWeb; 070 import railo.runtime.config.ConfigWebAdmin; 071 import railo.runtime.config.ConfigWebFactory; 072 import railo.runtime.config.ConfigWebImpl; 073 import railo.runtime.config.ConfigWebUtil; 074 import railo.runtime.config.DebugEntry; 075 import railo.runtime.config.DeployHandler; 076 import railo.runtime.config.RemoteClient; 077 import railo.runtime.config.RemoteClientImpl; 078 import railo.runtime.db.DataSource; 079 import railo.runtime.db.DataSourceImpl; 080 import railo.runtime.db.DataSourceManager; 081 import railo.runtime.engine.CFMLEngineImpl; 082 import railo.runtime.engine.ExecutionLogFactory; 083 import railo.runtime.engine.ThreadLocalPageContext; 084 import railo.runtime.exp.ApplicationException; 085 import railo.runtime.exp.DatabaseException; 086 import railo.runtime.exp.DeprecatedException; 087 import railo.runtime.exp.PageException; 088 import railo.runtime.exp.PageExceptionImpl; 089 import railo.runtime.exp.SecurityException; 090 import railo.runtime.ext.tag.DynamicAttributes; 091 import railo.runtime.ext.tag.TagImpl; 092 import railo.runtime.extension.Extension; 093 import railo.runtime.extension.ExtensionImpl; 094 import railo.runtime.extension.ExtensionProvider; 095 import railo.runtime.functions.cache.Util; 096 import railo.runtime.functions.system.ContractPath; 097 import railo.runtime.gateway.GatewayEngineImpl; 098 import railo.runtime.gateway.GatewayEntry; 099 import railo.runtime.gateway.GatewayEntryImpl; 100 import railo.runtime.gateway.GatewayUtil; 101 import railo.runtime.i18n.LocaleFactory; 102 import railo.runtime.listener.AppListenerUtil; 103 import railo.runtime.listener.ApplicationListener; 104 import railo.runtime.monitor.IntervallMonitor; 105 import railo.runtime.monitor.Monitor; 106 import railo.runtime.monitor.RequestMonitor; 107 import railo.runtime.net.http.CertificateInstaller; 108 import railo.runtime.net.http.ReqRspUtil; 109 import railo.runtime.net.mail.SMTPException; 110 import railo.runtime.net.mail.SMTPVerifier; 111 import railo.runtime.net.mail.Server; 112 import railo.runtime.net.mail.ServerImpl; 113 import railo.runtime.net.proxy.ProxyData; 114 import railo.runtime.net.proxy.ProxyDataImpl; 115 import railo.runtime.op.Caster; 116 import railo.runtime.op.Decision; 117 import railo.runtime.op.Duplicator; 118 import railo.runtime.op.date.DateCaster; 119 import railo.runtime.orm.ORMConfiguration; 120 import railo.runtime.orm.ORMConfigurationImpl; 121 import railo.runtime.reflection.Reflector; 122 import railo.runtime.rest.RestUtil; 123 import railo.runtime.security.SecurityManager; 124 import railo.runtime.security.SecurityManagerImpl; 125 import railo.runtime.spooler.ExecutionPlan; 126 import railo.runtime.spooler.SpoolerEngineImpl; 127 import railo.runtime.spooler.SpoolerTask; 128 import railo.runtime.spooler.remote.RemoteClientTask; 129 import railo.runtime.type.Array; 130 import railo.runtime.type.ArrayImpl; 131 import railo.runtime.type.Collection; 132 import railo.runtime.type.Collection.Key; 133 import railo.runtime.type.KeyImpl; 134 import railo.runtime.type.Query; 135 import railo.runtime.type.QueryImpl; 136 import railo.runtime.type.Struct; 137 import railo.runtime.type.StructImpl; 138 import railo.runtime.type.dt.DateTime; 139 import railo.runtime.type.dt.DateTimeImpl; 140 import railo.runtime.type.dt.TimeSpan; 141 import railo.runtime.type.scope.Cluster; 142 import railo.runtime.type.scope.ClusterEntryImpl; 143 import railo.runtime.type.util.ComponentUtil; 144 import railo.runtime.type.util.KeyConstants; 145 import railo.transformer.library.function.FunctionLib; 146 import railo.transformer.library.tag.TagLib; 147 148 /** 149 * 150 */ 151 public final class Admin extends TagImpl implements DynamicAttributes { 152 153 private static final short TYPE_WEB=0; 154 private static final short TYPE_SERVER=1; 155 156 private static final short ACCESS_FREE=0; 157 private static final short ACCESS_NOT_WHEN_WEB=1; 158 private static final short ACCESS_NOT_WHEN_SERVER=2; 159 private static final short ACCESS_NEVER=3; 160 161 private static final short ACCESS_READ=10; 162 private static final short ACCESS_WRITE=11; 163 private static final short CHECK_PW=12; 164 165 //private static final String USAGE_SYNC = "synchronisation"; 166 //private static final String USAGE_CLUSTER = "cluster"; 167 public static final String[] ORM_JARS = new String[]{"antlr.jar","dom4j.jar","hibernate.jar","javassist.jar","jta.jar","slf4j-api.jar","railo-sl4j.jar"}; 168 public static final String[] CACHE_JARS = new String[]{"ehcache.jar"}; 169 public static final String[] CFX_JARS = new String[]{"com.naryx.tagfusion.cfx.jar"}; 170 public static final String[] UPDATE_JARS = new String[]{"railo-inst.jar","ehcache.jar","antlr.jar","dom4j.jar","hibernate.jar","javassist.jar","jta.jar","slf4j-api.jar","railo-sl4j.jar","metadata-extractor.jar","icepdf-core.jar","com.naryx.tagfusion.cfx.jar"}; 171 172 173 private static final Collection.Key DEBUG = KeyConstants._debug; 174 //private static final Collection.Key DEBUG_TEMPLATE = KeyImpl.intern("debugTemplate"); 175 private static final Collection.Key DEBUG_SHOW_QUERY_USAGE = KeyImpl.intern("debugShowQueryUsage"); 176 //private static final Collection.Key STR_DEBUG_TEMPLATE = KeyImpl.intern("strdebugTemplate"); 177 private static final Collection.Key TEMPLATES = KeyConstants._templates; 178 private static final Collection.Key STR = KeyConstants._str; 179 private static final Collection.Key DO_STATUS_CODE = KeyImpl.intern("doStatusCode"); 180 private static final Collection.Key LABEL = KeyConstants._label; 181 private static final Collection.Key HASH = KeyConstants._hash; 182 private static final Collection.Key ROOT = KeyConstants._root; 183 private static final Collection.Key FILE_ACCESS = KeyImpl.intern("file_access"); 184 private static final Collection.Key IP_RANGE = KeyImpl.intern("ipRange"); 185 private static final Collection.Key CUSTOM = KeyConstants._custom; 186 private static final Collection.Key READONLY = KeyImpl.intern("readOnly"); 187 private static final Collection.Key LOG_ENABLED = KeyImpl.intern("logEnabled"); 188 private static final Collection.Key CLASS = KeyConstants._class; 189 190 private static final Key HAS_OWN_SEC_CONTEXT = KeyImpl.intern("hasOwnSecContext"); 191 private static final Key CONFIG_FILE = KeyImpl.intern("config_file"); 192 private static final Key PROCEDURE = KeyImpl.intern("procedure"); 193 private static final Key SERVER_LIBRARY = KeyImpl.intern("serverlibrary"); 194 private static final Key KEEP_ALIVE = KeyImpl.intern("keepalive"); 195 196 private static final short MAPPING_REGULAR = 1; 197 private static final short MAPPING_CT = 2; 198 private static final short MAPPING_CFC = 4; 199 200 201 202 /* 203 others: 204 PDFRenderer.jar 205 ? 206 xmlparserv2.jar 207 208 not needed: 209 slf4j-simple.jar 210 xdb.jar 211 212 213 214 */ 215 216 217 218 private Struct attributes=new StructImpl(); 219 private String action=null; 220 private short type; 221 private String password; 222 private ConfigWebAdmin admin; 223 private ConfigImpl config; 224 225 private static final ResourceFilter FILTER_CFML_TEMPLATES=new LogResourceFilter( 226 new OrResourceFilter(new ResourceFilter[]{ 227 new DirectoryResourceFilter(), 228 new ExtensionResourceFilter("cfm"), 229 new ExtensionResourceFilter("cfc"), 230 new ExtensionResourceFilter("cfml") 231 })); 232 private AdminSync adminSync; 233 234 235 236 @Override 237 public void release() { 238 super.release(); 239 attributes.clear(); 240 } 241 242 @Override 243 public void setDynamicAttribute(String uri, String localName, Object value) { 244 attributes.setEL(KeyImpl.getInstance(localName),value); 245 } 246 public void setDynamicAttribute(String uri, Collection.Key localName, Object value) { 247 attributes.setEL(localName,value); 248 } 249 250 @Override 251 public int doStartTag() throws PageException { 252 //adminSync = pageContext.getAdminSync(); 253 254 // Action 255 Object objAction=attributes.get(KeyConstants._action); 256 if(objAction==null)throw new ApplicationException("missing attrbute action for tag admin"); 257 action=StringUtil.toLowerCase(Caster.toString(objAction)).trim(); 258 259 // Generals 260 if(action.equals("getlocales")) { 261 doGetLocales(); 262 return SKIP_BODY; 263 } 264 if(action.equals("gettimezones")) { 265 doGetTimeZones(); 266 return SKIP_BODY; 267 } 268 if(action.equals("printdebug")) { 269 throw new DeprecatedException("action [printdebug] is no longer supported, use instead [getdebugdata]"); 270 } 271 if(action.equals("getdebugdata")) { 272 doGetDebugData(); 273 return SKIP_BODY; 274 } 275 if(action.equals("getloginsettings")) { 276 doGetLoginSettings(); 277 return SKIP_BODY; 278 } 279 280 // Type 281 type=toType(getString("type","web"),true); 282 283 // has Password 284 if(action.equals("haspassword")) { 285 //long start=System.currentTimeMillis(); 286 boolean hasPassword=type==TYPE_WEB? 287 pageContext.getConfig().hasPassword(): 288 pageContext.getConfig().hasServerPassword(); 289 290 pageContext.setVariable(getString("admin",action,"returnVariable",true),Caster.toBoolean(hasPassword)); 291 return SKIP_BODY; 292 } 293 294 // update Password 295 else if(action.equals("updatepassword")) { 296 try { 297 ((ConfigWebImpl)pageContext.getConfig()).setPassword(type!=TYPE_WEB, 298 getString("oldPassword",null),getString("admin",action,"newPassword",true)); 299 } 300 catch (Exception e) { 301 throw Caster.toPageException(e); 302 } 303 return SKIP_BODY; 304 } 305 306 307 try { 308 // Password 309 password = getString("password",""); 310 // Config 311 config=(ConfigImpl)pageContext.getConfig(); 312 if(type==TYPE_SERVER) 313 config=(ConfigImpl)config.getConfigServer(password); 314 315 adminSync = config.getAdminSync(); 316 admin = ConfigWebAdmin.newInstance(config,password); 317 } 318 catch (Exception e) { 319 throw Caster.toPageException(e); 320 } 321 //int version=config.getSerialNumber().getVersion(); 322 /*if(type==TYPE_SERVER && version!=SerialNumber.VERSION_ENTERPRISE && version!=SerialNumber.VERSION_DEVELOP) 323 throw new SecurityException("can't access server settings with "+config.getSerialNumber().getStringVersion()+ 324 " version of Railo"); 325 326 */ 327 328 try { 329 _doStartTag(); 330 } catch (IOException e) { 331 throw Caster.toPageException(e); 332 } 333 334 return Tag.SKIP_BODY; 335 } 336 337 private short toType(String strType, boolean throwError) throws ApplicationException { 338 strType=StringUtil.toLowerCase(strType).trim(); 339 if("web".equals(strType))return TYPE_WEB; 340 else if("server".equals(strType))return TYPE_SERVER; 341 if(throwError) 342 throw new ApplicationException("invalid value for attribute type ["+strType+"] of tag admin","valid values are web, server, all"); 343 return TYPE_WEB; 344 } 345 346 private void doTagSchedule() throws PageException { 347 Schedule schedule=new Schedule(); 348 try { 349 350 351 schedule.setPageContext(pageContext); 352 schedule.setAction(getString("admin",action,"scheduleAction")); 353 schedule.setTask(getString("task",null)); 354 schedule.setHidden(getBoolV("hidden",false)); 355 schedule.setReadonly(getBoolV("readonly",false)); 356 schedule.setOperation(getString("operation",null)); 357 schedule.setFile(getString("file",null)); 358 schedule.setPath(getString("path",null)); 359 schedule.setStartdate(getObject("startDate",null)); 360 schedule.setStarttime(getObject("startTime",null)); 361 schedule.setUrl(getString("url",null)); 362 schedule.setPublish(getBoolV("publish",false)); 363 schedule.setEnddate(getObject("endDate",null)); 364 schedule.setEndtime(getObject("endTime",null)); 365 schedule.setInterval(getString("interval",null)); 366 schedule.setRequesttimeout(new Double(getDouble("requestTimeOut",-1))); 367 schedule.setUsername(getString("username",null)); 368 schedule.setPassword(getString("schedulePassword",null)); 369 schedule.setProxyserver(getString("proxyServer",null)); 370 schedule.setProxyuser(getString("proxyuser",null)); 371 schedule.setProxypassword(getString("proxyPassword",null)); 372 schedule.setResolveurl(getBoolV("resolveURL",false)); 373 schedule.setPort(new Double(getDouble("port",-1))); 374 schedule.setProxyport(new Double(getDouble("proxyPort",80))); 375 schedule.setReturnvariable(getString("returnvariable","cfschedule")); 376 377 schedule.doStartTag(); 378 } 379 finally { 380 schedule.release(); 381 adminSync.broadcast(attributes, config); 382 adminSync.broadcast(attributes, config); 383 } 384 } 385 386 /*private void doTagSearch() throws PageException { 387 Search search=new Search(); 388 try { 389 390 search.setPageContext(pageContext); 391 392 search.setName(getString("admin",action,"name")); 393 search.setCollection(getString("admin",action,"collection")); 394 search.setType(getString("type",null)); 395 search.setMaxrows(getDouble("maxRows",-1)); 396 search.setStartrow(getDouble("startRow",1)); 397 search.setCategory(getString("category",null)); 398 search.setCategorytree(getString("categoryTree",null)); 399 search.setStatus(getString("status",null)); 400 search.setSuggestions(getString("suggestions",null)); 401 402 search.doStartTag(); 403 } 404 finally { 405 search.release(); 406 } 407 }*/ 408 409 private void doTagIndex() throws PageException { 410 Index index=new Index(); 411 try { 412 413 index.setPageContext(pageContext); 414 415 index.setCollection(getString("admin",action,"collection")); 416 index.setAction(getString("admin",action,"indexAction")); 417 index.setType(getString("indexType",null)); 418 index.setTitle(getString("title",null)); 419 index.setKey(getString("key",null)); 420 index.setBody(getString("body",null)); 421 index.setCustom1(getString("custom1",null)); 422 index.setCustom2(getString("custom2",null)); 423 index.setCustom3(getString("custom3",null)); 424 index.setCustom4(getString("custom4",null)); 425 index.setUrlpath(getString("URLpath",null)); 426 index.setExtensions(getString("extensions",null)); 427 index.setQuery(getString("query",null)); 428 index.setRecurse(getBoolV("recurse",false)); 429 index.setLanguage(getString("language",null)); 430 index.setCategory(getString("category",null)); 431 index.setCategorytree(getString("categoryTree",null)); 432 index.setStatus(getString("status",null)); 433 index.setPrefix(getString("prefix",null)); 434 435 index.doStartTag(); 436 } 437 finally { 438 index.release(); 439 adminSync.broadcast(attributes, config); 440 } 441 } 442 443 444 private void doTagCollection() throws PageException { 445 railo.runtime.tag.Collection coll=new railo.runtime.tag.Collection(); 446 try { 447 448 coll.setPageContext(pageContext); 449 450 //coll.setCollection(getString("admin",action,"collection")); 451 coll.setAction(getString("collectionAction",null)); 452 coll.setCollection(getString("collection",null)); 453 coll.setPath(getString("path",null)); 454 coll.setLanguage(getString("language",null)); 455 coll.setName(getString("name",null)); 456 457 458 coll.doStartTag(); 459 } 460 finally { 461 coll.release(); 462 adminSync.broadcast(attributes, config); 463 } 464 } 465 466 /** 467 * @throws PageException 468 * 469 */ 470 private void _doStartTag() throws PageException,IOException { 471 472 473 // getToken 474 if(action.equals("gettoken")) { 475 doGetToken(); 476 return; 477 } 478 479 480 // schedule 481 if(action.equals("schedule")) { 482 doTagSchedule(); 483 return; 484 } 485 // search 486 if(action.equals("collection")) { 487 doTagCollection(); 488 return; 489 } 490 // index 491 if(action.equals("index")) { 492 doTagIndex(); 493 return; 494 } 495 // cluster 496 if(action.equals("setcluster")) { 497 doSetCluster(); 498 return; 499 } 500 if(action.equals("getcluster")) { 501 doGetCluster(); 502 return; 503 } 504 505 506 507 if(check("connect",ACCESS_FREE) && check2(CHECK_PW)) { 508 try{ 509 if(config instanceof ConfigServer) 510 ((PageContextImpl)pageContext).setServerPassword(password); 511 } 512 catch(Throwable t){} 513 } 514 else if(check("getinfo", ACCESS_FREE) && check2(ACCESS_READ )) doGetInfo(); 515 else if(check("surveillance", ACCESS_FREE) && check2(ACCESS_READ )) doSurveillance(); 516 else if(check("getRegional", ACCESS_FREE) && check2(ACCESS_READ )) doGetRegional(); 517 else if(check("isMonitorEnabled", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_READ )) doIsMonitorEnabled(); 518 else if(check("resetORMSetting", ACCESS_FREE) && check2(ACCESS_READ )) doResetORMSetting(); 519 else if(check("getORMSetting", ACCESS_FREE) && check2(ACCESS_READ )) doGetORMSetting(); 520 else if(check("getORMEngine", ACCESS_FREE) && check2(ACCESS_READ )) doGetORMEngine(); 521 else if(check("updateORMSetting", ACCESS_FREE) && check2(ACCESS_READ )) doUpdateORMSetting(); 522 else if(check("getApplicationListener", ACCESS_FREE) && check2(ACCESS_READ )) doGetApplicationListener(); 523 else if(check("getProxy", ACCESS_FREE) && check2(ACCESS_READ )) doGetProxy(); 524 else if(check("getCharset", ACCESS_FREE) && check2(ACCESS_READ )) doGetCharset(); 525 else if(check("getComponent", ACCESS_FREE) && check2(ACCESS_READ )) doGetComponent(); 526 else if(check("getScope", ACCESS_FREE) && check2(ACCESS_READ )) doGetScope(); 527 else if(check("getApplicationSetting", ACCESS_FREE) && check2(ACCESS_READ )) doGetApplicationSetting(); 528 else if(check("getOutputSetting", ACCESS_FREE) && check2(ACCESS_READ )) doGetOutputSetting(); 529 else if(check("getDatasourceSetting", ACCESS_FREE) && check2(ACCESS_READ )) doGetDatasourceSetting(); 530 else if(check("getCustomTagSetting", ACCESS_FREE) && check2(ACCESS_READ )) doGetCustomTagSetting(); 531 else if(check("getDatasource", ACCESS_FREE) && check2(ACCESS_READ )) doGetDatasource(); 532 else if(check("getCacheConnections", ACCESS_FREE) && check2(ACCESS_READ )) doGetCacheConnections(); 533 else if(check("getCacheConnection", ACCESS_FREE) && check2(ACCESS_READ )) doGetCacheConnection(); 534 else if(check("getCacheDefaultConnection",ACCESS_FREE) && check2(ACCESS_READ )) doGetCacheDefaultConnection(); 535 else if(check("getDatasources", ACCESS_FREE) && check2(ACCESS_READ )) doGetDatasources(); 536 else if(check("getRemoteClients", ACCESS_FREE) && check2(ACCESS_READ )) doGetRemoteClients(); 537 else if(check("getRemoteClient", ACCESS_FREE) && check2(ACCESS_READ )) doGetRemoteClient(); 538 else if(check("hasRemoteClientUsage", ACCESS_FREE) && check2(ACCESS_READ )) doHasRemoteClientUsage(); 539 else if(check("getRemoteClientUsage", ACCESS_FREE) && check2(ACCESS_READ )) doGetRemoteClientUsage(); 540 else if(check("getSpoolerTasks", ACCESS_FREE) && check2(ACCESS_READ )) doGetSpoolerTasks(); 541 else if(check("getPerformanceSettings", ACCESS_FREE) && check2(ACCESS_READ )) doGetPerformanceSettings(); 542 else if(check("getLogSetting", ACCESS_FREE) && check2(ACCESS_READ )) doGetLogSetting(); 543 else if(check("getLogSettings", ACCESS_FREE) && check2(ACCESS_READ )) doGetLogSettings(); 544 else if(check("getCompilerSettings", ACCESS_FREE) && check2(ACCESS_READ )) doGetCompilerSettings(); 545 else if(check("updatePerformanceSettings",ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdatePerformanceSettings(); 546 else if(check("updateCompilerSettings",ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateCompilerSettings(); 547 else if(check("getGatewayentries", ACCESS_NOT_WHEN_SERVER) && check2(ACCESS_READ )) doGetGatewayEntries(); 548 else if(check("getGatewayentry", ACCESS_NOT_WHEN_SERVER) && check2(ACCESS_READ )) doGetGatewayEntry(); 549 else if(check("getRunningThreads", ACCESS_FREE) && check2(ACCESS_READ )) doGetRunningThreads(); 550 else if(check("getMonitors", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_READ )) doGetMonitors(); 551 else if(check("getMonitor", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_READ )) doGetMonitor(); 552 else if(check("getExecutionLog", ACCESS_FREE) && check2(ACCESS_READ )) doGetExecutionLog(); 553 else if(check("gateway", ACCESS_NOT_WHEN_SERVER) && check2(ACCESS_READ )) doGateway(); 554 555 556 557 // alias for getSpoolerTasks 558 else if(check("getRemoteClientTasks", ACCESS_FREE) && check2(ACCESS_READ )) doGetSpoolerTasks(); 559 else if(check("getDatasourceDriverList",ACCESS_FREE) && check2(ACCESS_READ )) doGetDatasourceDriverList(); 560 else if(check("getDebuggingList", ACCESS_FREE) && check2(ACCESS_READ )) doGetDebuggingList(); 561 else if(check("getLoggedDebugData", ACCESS_FREE) && check2(ACCESS_READ )) doGetLoggedDebugData(); 562 else if(check("getDebugSetting", ACCESS_FREE) && check2(ACCESS_READ )) doGetDebugSetting(); 563 else if(check("getSSLCertificate", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_READ )) doGetSSLCertificate(); 564 else if(check("getPluginDirectory", ACCESS_FREE) && check2(ACCESS_READ )) doGetPluginDirectory(); 565 else if(check("getPlugins", ACCESS_FREE) && check2(ACCESS_READ )) doGetPlugins(); 566 else if(check("updatePlugin", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdatePlugin(); 567 else if(check("removePlugin", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemovePlugin(); 568 569 else if(check("getContextDirectory",ACCESS_NOT_WHEN_WEB) && check2(ACCESS_READ )) getContextDirectory(); 570 else if(check("updateContext", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doUpdateContext(); 571 else if(check("removeContext", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doRemoveContext(); 572 573 else if(check("getJars", ACCESS_FREE) && check2(ACCESS_READ )) doGetJars(); 574 else if(check("getFlds", ACCESS_FREE) && check2(ACCESS_READ )) doGetFLDs(); 575 else if(check("getTlds", ACCESS_FREE) && check2(ACCESS_READ )) doGetTLDs(); 576 else if(check("getMailSetting", ACCESS_FREE) && check2(ACCESS_READ )) doGetMailSetting(); 577 else if(check("getMailServers", ACCESS_FREE) && check2(ACCESS_READ )) doGetMailServers(); 578 else if(check("getMapping", ACCESS_FREE) && check2(ACCESS_READ )) doGetMapping(); 579 else if(check("getMappings", ACCESS_FREE) && check2(ACCESS_READ )) doGetMappings(); 580 else if(check("getRestMappings", ACCESS_FREE) && check2(ACCESS_READ )) doGetRestMappings(); 581 else if(check("getRestSettings", ACCESS_FREE) && check2(ACCESS_READ )) doGetRestSettings(); 582 else if(check("getExtensions", ACCESS_FREE) && check2(ACCESS_READ )) doGetExtensions(); 583 else if(check("getExtensionProviders", ACCESS_FREE) && check2(ACCESS_READ )) doGetExtensionProviders(); 584 else if(check("getExtensionInfo", ACCESS_FREE) && check2(ACCESS_READ )) doGetExtensionInfo(); 585 586 else if(check("getCustomTagMappings", ACCESS_FREE) && check2(ACCESS_READ )) doGetCustomTagMappings(); 587 else if(check("getComponentMappings", ACCESS_FREE) && check2(ACCESS_READ )) doGetComponentMappings(); 588 else if(check("getCfxTags", ACCESS_FREE) && check2(ACCESS_READ )) doGetCFXTags(); 589 else if(check("getCPPCfxTags", ACCESS_FREE) && check2(ACCESS_READ )) doGetCPPCFXTags(); 590 else if(check("getJavaCfxTags", ACCESS_FREE) && check2(ACCESS_READ )) doGetJavaCFXTags(); 591 else if(check("getDebug", ACCESS_FREE) && check2(ACCESS_READ )) doGetDebug(); 592 else if(check("getDebugEntry", ACCESS_FREE) && check2(ACCESS_READ )) doGetDebugEntry(); 593 else if(check("getError", ACCESS_FREE) && check2(ACCESS_READ )) doGetError(); 594 else if(check("verifyremoteclient", ACCESS_FREE) && check2(ACCESS_READ )) doVerifyRemoteClient(); 595 else if(check("verifyDatasource", ACCESS_FREE) && check2(ACCESS_READ )) doVerifyDatasource(); 596 else if(check("verifyCacheConnection", ACCESS_FREE) && check2(ACCESS_READ )) doVerifyCacheConnection(); 597 else if(check("verifyMailServer", ACCESS_FREE) && check2(ACCESS_READ )) doVerifyMailServer(); 598 else if(check("verifyExtensionProvider",ACCESS_FREE) && check2(ACCESS_READ )) doVerifyExtensionProvider(); 599 else if(check("verifyJavaCFX", ACCESS_FREE) && check2(ACCESS_READ )) doVerifyJavaCFX(); 600 else if(check("verifyCFX", ACCESS_FREE) && check2(ACCESS_READ )) doVerifyCFX(); 601 602 else if(check("resetId", ACCESS_FREE) && check2(ACCESS_WRITE )) doResetId(); 603 else if(check("updateLoginSettings", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doUpdateLoginSettings(); 604 else if(check("updateJar", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateJar(); 605 else if(check("updateSSLCertificate",ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doUpdateSSLCertificate(); 606 else if(check("updateMonitorEnabled", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doUpdateMonitorEnabled(); 607 else if(check("updateTLD", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateTLD(); 608 else if(check("updateFLD", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateFLD(); 609 else if(check("updateregional", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateRegional(); 610 else if(check("updateApplicationListener",ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateApplicationListener(); 611 else if(check("updateproxy", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateProxy(); 612 else if(check("updateCharset", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateCharset(); 613 else if(check("updatecomponent", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateComponent(); 614 else if(check("updatescope", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateScope(); 615 else if(check("updateRestSettings", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateRestSettings(); 616 else if(check("updateRestMapping", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateRestMapping(); 617 else if(check("removeRestMapping", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveRestMapping(); 618 else if(check("updateApplicationSetting",ACCESS_FREE) && check2(ACCESS_WRITE ))doUpdateApplicationSettings(); 619 else if(check("updateOutputSetting", ACCESS_FREE) && check2(ACCESS_WRITE ))doUpdateOutputSettings(); 620 else if(check("updatepsq", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdatePSQ(); 621 else if(check("updatedatasource", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateDatasource(); 622 else if(check("updateCacheDefaultConnection",ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateCacheDefaultConnection(); 623 else if(check("updateCacheConnection", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateCacheConnection(); 624 else if(check("updateremoteclient", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateRemoteClient(); 625 else if(check("updateRemoteClientUsage",ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateRemoteClientUsage(); 626 else if(check("updatemailsetting", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateMailSetting(); 627 else if(check("updatemailserver", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateMailServer(); 628 else if(check("updatemapping", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateMapping(); 629 else if(check("updatecustomtag", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateCustomTag(); 630 else if(check("updateComponentMapping", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateComponentMapping(); 631 else if(check("stopThread", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doStopThread(); 632 633 634 else if(check("updatejavacfx", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateJavaCFX(); 635 else if(check("updatecppcfx", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateCPPCFX(); 636 else if(check("updatedebug", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateDebug(); 637 else if(check("updatedebugentry", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateDebugEntry(); 638 else if(check("updatedebugsetting", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateDebugSetting(); 639 640 else if(check("updateerror", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateError(); 641 else if(check("updateCustomTagSetting", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateCustomTagSetting(); 642 else if(check("updateExtension", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateExtension(); 643 else if(check("updateRHExtension", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateRHExtension(); 644 else if(check("updateExtensionProvider",ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateExtensionProvider(); 645 else if(check("updateExtensionInfo", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateExtensionInfo(); 646 else if(check("updateGatewayEntry", ACCESS_NOT_WHEN_SERVER) && check2(ACCESS_WRITE )) doUpdateGatewayEntry(); 647 else if(check("updateLogSettings", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateUpdateLogSettings(); 648 else if(check("updateMonitor", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doUpdateMonitor(); 649 else if(check("updateExecutionLog", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateExecutionLog(); 650 651 652 //else if(check("removeproxy", ACCESS_NOT_WHEN_SERVER )) doRemoveProxy(); 653 else if(check("removeMonitor", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doRemoveMonitor(); 654 else if(check("removejar", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveJar(); 655 else if(check("removeTLD", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveTLD(); 656 else if(check("removeFLD", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveFLD(); 657 else if(check("removedatasource", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveDatasource(); 658 else if(check("removeCacheConnection", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveCacheConnection(); 659 else if(check("removeremoteclient", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveRemoteClient(); 660 else if(check("removeRemoteClientUsage",ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveRemoteClientUsage(); 661 else if(check("removeSpoolerTask", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveSpoolerTask(); 662 else if(check("removeAllSpoolerTask", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveAllSpoolerTask(); 663 // alias for executeSpoolerTask 664 else if(check("removeRemoteClientTask", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveSpoolerTask(); 665 else if(check("executeSpoolerTask", ACCESS_FREE) && check2(ACCESS_WRITE )) doExecuteSpoolerTask(); 666 // alias for executeSpoolerTask 667 else if(check("executeRemoteClientTask",ACCESS_FREE) && check2(ACCESS_WRITE )) doExecuteSpoolerTask(); 668 else if(check("removemailserver", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveMailServer(); 669 else if(check("removemapping", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveMapping(); 670 else if(check("removecustomtag", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveCustomTag(); 671 else if(check("removecomponentmapping", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveComponentMapping(); 672 else if(check("removecfx", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveCFX(); 673 else if(check("removeExtension", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveExtension(); 674 else if(check("removeExtensionProvider",ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveExtensionProvider(); 675 else if(check("removeDefaultPassword", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveDefaultPassword(); 676 else if(check("removeGatewayEntry", ACCESS_NOT_WHEN_SERVER) && check2(ACCESS_WRITE )) doRemoveGatewayEntry(); 677 else if(check("removeDebugEntry", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveDebugEntry(); 678 else if(check("removeCacheDefaultConnection",ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveCacheDefaultConnection(); 679 680 else if(check("storageGet", ACCESS_FREE) && check2(ACCESS_READ )) doStorageGet(); 681 else if(check("storageSet", ACCESS_FREE) && check2(ACCESS_WRITE )) doStorageSet(); 682 683 else if(check("getdefaultpassword", ACCESS_FREE) && check2(ACCESS_READ )) doGetDefaultPassword(); 684 else if(check("getContexts", ACCESS_FREE) && check2(ACCESS_READ )) doGetContexts(); 685 else if(check("getContextes", ACCESS_FREE) && check2(ACCESS_READ )) doGetContexts(); 686 else if(check("updatedefaultpassword", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateDefaultPassword(); 687 else if(check("hasindividualsecurity", ACCESS_FREE) && check2(ACCESS_READ )) doHasIndividualSecurity(); 688 else if(check("resetpassword", ACCESS_FREE) && check2(ACCESS_WRITE )) doResetPassword(); 689 else if(check("stopThread", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doStopThread(); 690 691 else if(check("createsecuritymanager", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doCreateSecurityManager(); 692 else if(check("getsecuritymanager", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_READ )) doGetSecurityManager(); 693 else if(check("removesecuritymanager", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doRemoveSecurityManager(); 694 else if(check("getdefaultsecuritymanager",ACCESS_NOT_WHEN_WEB) && check2(ACCESS_READ )) doGetDefaultSecurityManager(); 695 else if(check("updatesecuritymanager", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doUpdateSecurityManager(); 696 else if(check("updatedefaultsecuritymanager",ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doUpdateDefaultSecurityManager(); 697 else if(check("compileMapping", ACCESS_FREE) && check2(ACCESS_WRITE )) doCompileMapping(); 698 else if(check("compileComponentMapping", ACCESS_FREE) && check2(ACCESS_WRITE )) doCompileComponentMapping(); 699 else if(check("compileCTMapping", ACCESS_FREE) && check2(ACCESS_WRITE )) doCompileCTMapping(); 700 else if(check("createArchive", ACCESS_FREE) && check2(ACCESS_WRITE )) doCreateArchive(MAPPING_REGULAR); 701 else if(check("createComponentArchive", ACCESS_FREE) && check2(ACCESS_WRITE )) doCreateArchive(MAPPING_CFC); 702 else if(check("createCTArchive", ACCESS_FREE) && check2(ACCESS_WRITE )) doCreateArchive(MAPPING_CT); 703 else if(check("reload", ACCESS_FREE) && check2(ACCESS_WRITE )) doReload(); 704 705 706 else if(check("getResourceProviders", ACCESS_FREE) && check2(ACCESS_READ )) doGetResourceProviders(); 707 else if(check("updateResourceProvider", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateResourceProvider(); 708 else if(check("updateDefaultResourceProvider", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateDefaultResourceProvider(); 709 else if(check("removeResourceProvider", ACCESS_FREE) && check2(ACCESS_WRITE )) doRemoveResourceProvider(); 710 711 else if(check("getClusterClass", ACCESS_FREE) && check2(ACCESS_READ )) doGetClusterClass(); 712 else if(check("updateClusterClass", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateClusterClass(); 713 714 else if(check("getAdminSyncClass", ACCESS_FREE) && check2(ACCESS_READ )) doGetAdminSyncClass(); 715 else if(check("updateAdminSyncClass", ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateAdminSyncClass(); 716 717 else if(check("getVideoExecuterClass", ACCESS_FREE) && check2(ACCESS_READ )) doGetVideoExecuterClass(); 718 else if(check("updateVideoExecuterClass",ACCESS_FREE) && check2(ACCESS_WRITE )) doUpdateVideoExecuterClass(); 719 else if(check("terminateRunningThread",ACCESS_FREE) && check2(ACCESS_WRITE )) doTerminateRunningThread(); 720 721 else if(check("updateLabel", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doUpdateLabel(); 722 else if(check("restart", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doRestart(); 723 else if(check("runUpdate", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doRunUpdate(); 724 else if(check("removeUpdate", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doRemoveUpdate(); 725 else if(check("getUpdate", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doGetUpdate(); 726 else if(check("listPatches", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_READ )) listPatches(); 727 else if(check("needNewJars", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_READ )) needNewJars(); 728 else if(check("updateJars", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doUpdateJars(); 729 else if(check("updateupdate", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doUpdateUpdate(); 730 else if(check("getSerial", ACCESS_FREE) && check2(ACCESS_READ )) doGetSerial(); 731 else if(check("updateSerial", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doUpdateSerial(); 732 else if(check("heapDump", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE )) doHeapDump(); 733 else if(check("securitymanager", ACCESS_FREE) && check2(ACCESS_READ )) doSecurityManager(); 734 735 736 737 else throw new ApplicationException("invalid action ["+action+"] for tag admin"); 738 739 } 740 741 private boolean check2(short accessRW) throws SecurityException { 742 if(accessRW==ACCESS_READ) ConfigWebUtil.checkGeneralReadAccess(config,password); 743 else if(accessRW==ACCESS_WRITE) ConfigWebUtil.checkGeneralWriteAccess(config,password); 744 else if(accessRW==CHECK_PW) { 745 ConfigWebUtil.checkGeneralReadAccess(config,password); 746 ConfigWebUtil.checkPassword(config,null,password); 747 } 748 return true; 749 } 750 private boolean check(String action, short access) throws ApplicationException { 751 if( this.action.equalsIgnoreCase(action)) { 752 if(access==ACCESS_FREE) { 753 } 754 else if(access==ACCESS_NOT_WHEN_SERVER) { 755 throwNoAccessWhenServer(); 756 } 757 758 else if(access==ACCESS_NOT_WHEN_WEB) { 759 throwNoAccessWhenWeb(); 760 } 761 else if(access==ACCESS_NEVER) { 762 throwNoAccessWhenServer(); 763 throwNoAccessWhenServer(); 764 } 765 return true; 766 } 767 return false; 768 } 769 770 771 private void doRunUpdate() throws PageException { 772 doUpdateJars(); 773 admin.runUpdate(password); 774 adminSync.broadcast(attributes, config); 775 } 776 777 private void doRemoveUpdate() throws PageException { 778 boolean onlyLatest = getBoolV("onlyLatest", false); 779 780 781 if(onlyLatest) admin.removeLatestUpdate(password); 782 else admin.removeUpdate(password); 783 adminSync.broadcast(attributes, config); 784 } 785 786 private void doRestart() throws PageException { 787 admin.restart(password); 788 adminSync.broadcast(attributes, config); 789 } 790 791 private void doCreateArchive(short mappingType) throws PageException { 792 String virtual = getString("admin",action,"virtual").toLowerCase(); 793 String strFile = getString("admin",action,"file"); 794 Resource file = ResourceUtil.toResourceNotExisting(pageContext, strFile); 795 796 boolean addCFMLFiles = getBoolV("addCFMLFiles", true); 797 boolean addNonCFMLFiles=getBoolV("addNonCFMLFiles", true); 798 799 // compile 800 MappingImpl mapping = (MappingImpl) doCompileMapping(mappingType,virtual, true); 801 802 // class files 803 if(mapping==null)throw new ApplicationException("there is no mapping for ["+virtual+"]"); 804 if(!mapping.hasPhysical())throw new ApplicationException("mapping ["+virtual+"] has no physical directory"); 805 806 Resource classRoot = mapping.getClassRootDirectory(); 807 Resource temp = SystemUtil.getTempDirectory().getRealResource("mani-"+IDGenerator.stringId()); 808 Resource mani = temp.getRealResource("META-INF/MANIFEST.MF"); 809 810 try { 811 if(file.exists())file.delete(); 812 if(!file.exists())file.createFile(true); 813 814 ResourceFilter filter; 815 816 817 // include everything, no filter needed 818 if(addCFMLFiles && addNonCFMLFiles)filter=null; 819 // CFML Files but no other files 820 else if(addCFMLFiles) { 821 if(mappingType==MAPPING_CFC)filter=new ExtensionResourceFilter(new String[]{"class","cfc","MF"},true,true); 822 else filter=new ExtensionResourceFilter(new String[]{"class","cfm","cfml","cfc","MF"},true,true); 823 } 824 // No CFML Files, but all other files 825 else if(addNonCFMLFiles) { 826 filter=new NotResourceFilter(new ExtensionResourceFilter(new String[]{"cfm","cfml","cfc"},false,true)); 827 } 828 // no files at all 829 else { 830 filter=new ExtensionResourceFilter(new String[]{"class","MF"},true,true); 831 } 832 833 834 // create manifest 835 StringBuilder manifest=new StringBuilder(); 836 837 // id 838 manifest.append("mapping-id: \""); 839 manifest.append(MD5.getDigestAsString(mapping.getStrPhysical())); 840 manifest.append("\"\n"); 841 842 843 manifest.append("mapping-type: \""); 844 if(mappingType==MAPPING_CFC)manifest.append("cfc"); 845 else if(mappingType==MAPPING_CT)manifest.append("ct"); 846 else manifest.append("regular"); 847 manifest.append("\"\n"); 848 849 manifest.append("mapping-virtual-path: \""); 850 manifest.append(mapping.getVirtual()); 851 manifest.append("\"\n"); 852 853 // Hidden 854 manifest.append("mapping-hidden: "); 855 manifest.append(mapping.isHidden()); 856 manifest.append("\n"); 857 // Physical First 858 manifest.append("mapping-physical-first: "); 859 manifest.append(mapping.isPhysicalFirst()); 860 manifest.append("\n"); 861 // Readonly 862 manifest.append("mapping-readonly: "); 863 manifest.append(mapping.isReadonly()); 864 manifest.append("\n"); 865 // Top Level 866 manifest.append("mapping-top-level: "); 867 manifest.append(mapping.isTopLevel()); 868 manifest.append("\n"); 869 870 // Trusted 871 manifest.append("mapping-inspect: \""); 872 manifest.append(ConfigWebUtil.inspectTemplate(mapping.getInspectTemplateRaw(), "")); 873 manifest.append("\"\n"); 874 875 876 877 878 mani.createFile(true); 879 IOUtil.write(mani, manifest.toString(), "UTF-8", false); 880 881 // source files 882 Resource[] sources; 883 if(!addCFMLFiles && !addNonCFMLFiles) sources=new Resource[]{temp,classRoot}; 884 else sources=new Resource[]{temp,mapping.getPhysical(),classRoot}; 885 886 CompressUtil.compressZip(ResourceUtil.listResources(sources,filter), file, filter); 887 888 889 890 891 if(getBoolV("append", false)) { 892 if(mappingType==MAPPING_CFC) { 893 admin.updateComponentMapping( 894 mapping.getVirtual(), 895 mapping.getStrPhysical(), 896 strFile, 897 mapping.isPhysicalFirst()?"physical":"archive", 898 mapping.getInspectTemplateRaw()); 899 } 900 else if(mappingType==MAPPING_CT) { 901 admin.updateCustomTag( 902 mapping.getVirtual(), 903 mapping.getStrPhysical(), 904 strFile, 905 mapping.isPhysicalFirst()?"physical":"archive", 906 mapping.getInspectTemplateRaw()); 907 908 } 909 910 else 911 admin.updateMapping( 912 mapping.getVirtual(), 913 mapping.getStrPhysical(), 914 strFile, 915 mapping.isPhysicalFirst()?"physical":"archive", 916 mapping.getInspectTemplateRaw(), 917 mapping.isTopLevel() 918 ); 919 store(); 920 } 921 922 923 } 924 catch (IOException e) { 925 throw Caster.toPageException(e); 926 } 927 finally{ 928 ResourceUtil.removeEL(temp, true); 929 } 930 adminSync.broadcast(attributes, config); 931 } 932 private void doCompileMapping() throws PageException { 933 doCompileMapping(MAPPING_REGULAR,getString("admin",action,"virtual").toLowerCase(), getBoolV("stoponerror", true)); 934 adminSync.broadcast(attributes, config); 935 } 936 private void doCompileComponentMapping() throws PageException { 937 doCompileMapping(MAPPING_CFC,getString("admin",action,"virtual").toLowerCase(), getBoolV("stoponerror", true)); 938 adminSync.broadcast(attributes, config); 939 } 940 private void doCompileCTMapping() throws PageException { 941 doCompileMapping(MAPPING_CT,getString("admin",action,"virtual").toLowerCase(), getBoolV("stoponerror", true)); 942 adminSync.broadcast(attributes, config); 943 } 944 945 private Mapping doCompileMapping(short mappingType,String virtual, boolean stoponerror) throws PageException { 946 947 if(StringUtil.isEmpty(virtual))return null; 948 949 if(!StringUtil.startsWith(virtual,'/'))virtual='/'+virtual; 950 if(!StringUtil.endsWith(virtual,'/'))virtual+='/'; 951 952 Mapping[] mappings = null; 953 if(mappingType==MAPPING_CFC)mappings=config.getComponentMappings(); 954 else if(mappingType==MAPPING_CT)mappings=config.getCustomTagMappings(); 955 else mappings=config.getMappings(); 956 957 958 959 for(int i=0;i<mappings.length;i++) { 960 Mapping mapping = mappings[i]; 961 if(mapping.getVirtualLowerCaseWithSlash().equals(virtual)) { 962 Map<String,String> errors = stoponerror?null:new HashTable(); 963 doCompileFile(mapping,mapping.getPhysical(),"",errors); 964 if(errors!=null && errors.size()>0) { 965 StringBuilder sb=new StringBuilder(); 966 Iterator<String> it = errors.keySet().iterator(); 967 Object key; 968 while(it.hasNext()) { 969 key=it.next(); 970 if(sb.length()>0)sb.append("\n\n"); 971 sb.append(errors.get(key)); 972 973 } 974 throw new ApplicationException(sb.toString()); 975 } 976 return mapping; 977 } 978 } 979 return null; 980 } 981 982 private void doCompileFile(Mapping mapping,Resource file,String path,Map<String,String> errors) throws PageException { 983 if(ResourceUtil.exists(file)) { 984 if(file.isDirectory()) { 985 Resource[] files = file.listResources(FILTER_CFML_TEMPLATES); 986 if(files!=null)for(int i=0;i<files.length;i++) { 987 String p=path+'/'+files[i].getName(); 988 //print.ln(files[i]+" - "+p); 989 doCompileFile(mapping,files[i],p,errors); 990 } 991 } 992 else if(file.isFile()) { 993 PageSourceImpl ps=(PageSourceImpl) mapping.getPageSource(path); 994 995 996 try { 997 998 ps.clear(); 999 ps.loadPage(pageContext); 1000 //pageContext.compile(ps); 1001 } catch (PageException pe) { 1002 //PageException pe = pse.getPageException(); 1003 1004 String template=ps.getDisplayPath(); 1005 StringBuilder msg=new StringBuilder(pe.getMessage()); 1006 msg.append(", Error Occurred in File ["); 1007 msg.append(template); 1008 if(pe instanceof PageExceptionImpl) { 1009 try{ 1010 PageExceptionImpl pei=(PageExceptionImpl)pe; 1011 Array context = pei.getTagContext(config); 1012 if(context.size()>0){ 1013 msg.append(":"); 1014 msg.append(Caster.toString(((Struct)context.getE(1)).get("line"))); 1015 } 1016 } 1017 catch(Throwable t){} 1018 1019 } 1020 msg.append("]"); 1021 if(errors!=null) errors.put(template,msg.toString()); 1022 else throw new ApplicationException(msg.toString()); 1023 1024 } 1025 } 1026 } 1027 } 1028 1029 /** 1030 * @throws PageException 1031 * 1032 */ 1033 private void doResetPassword() throws PageException { 1034 1035 try { 1036 admin.setPassword(getString("contextPath",null),null); 1037 }catch (Exception e) {} 1038 store(); 1039 } 1040 1041 /** 1042 * @throws PageException 1043 */ 1044 private void doGetContexts() throws PageException { 1045 CFMLFactory[] factories; 1046 if(config instanceof ConfigServerImpl) { 1047 ConfigServerImpl cs=(ConfigServerImpl) config; 1048 factories = cs.getJSPFactories(); 1049 } 1050 else { 1051 ConfigWebImpl cw=(ConfigWebImpl) config; 1052 factories = new CFMLFactory[]{cw.getFactory()}; 1053 } 1054 1055 railo.runtime.type.Query qry= 1056 new QueryImpl( 1057 new Collection.Key[]{ 1058 KeyConstants._path, 1059 KeyConstants._id,KeyConstants._hash, 1060 KeyConstants._label, 1061 HAS_OWN_SEC_CONTEXT, 1062 KeyConstants._url, 1063 CONFIG_FILE}, 1064 factories.length,getString("admin",action,"returnVariable")); 1065 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 1066 ConfigWebImpl cw; 1067 for(int i=0;i<factories.length;i++) { 1068 int row=i+1; 1069 CFMLFactoryImpl factory = (CFMLFactoryImpl) factories[i]; 1070 cw = (ConfigWebImpl) factory.getConfig(); 1071 qry.setAtEL(KeyConstants._path,row,ReqRspUtil.getRootPath(factory.getConfigWebImpl().getServletContext())); 1072 1073 qry.setAtEL(CONFIG_FILE,row,factory.getConfigWebImpl().getConfigFile().getAbsolutePath()); 1074 if(factory.getURL()!=null)qry.setAtEL(KeyConstants._url,row,factory.getURL().toExternalForm()); 1075 1076 1077 qry.setAtEL(KeyConstants._id,row,factory.getConfig().getId()); 1078 qry.setAtEL(KeyConstants._hash,row,SystemUtil.hash(factory.getConfigWebImpl().getServletContext())); 1079 qry.setAtEL(KeyConstants._label,row,factory.getLabel()); 1080 qry.setAtEL(HAS_OWN_SEC_CONTEXT,row,Caster.toBoolean(cw.hasIndividualSecurityManager())); 1081 } 1082 } 1083 1084 private void doHasIndividualSecurity() throws PageException { 1085 pageContext.setVariable( 1086 getString("admin",action,"returnVariable"), 1087 Caster.toBoolean( 1088 config.getConfigServer(password).hasIndividualSecurityManager( 1089 getString("admin",action,"id") 1090 1091 ) 1092 ) 1093 ); 1094 } 1095 1096 private void doUpdateUpdate() throws PageException { 1097 admin.updateUpdate(getString("admin",action,"updatetype"),getString("admin",action,"updatelocation")); 1098 store(); 1099 adminSync.broadcast(attributes, config); 1100 } 1101 1102 /** 1103 * @throws PageException 1104 * 1105 */ 1106 private void doUpdateSerial() throws PageException { 1107 admin.updateSerial(getString("admin",action,"serial")); 1108 store(); 1109 pageContext.serverScope().reload(); 1110 } 1111 1112 /** 1113 * @throws PageException 1114 * 1115 */ 1116 private void doGetSerial() throws PageException { 1117 pageContext.setVariable( 1118 getString("admin",action,"returnVariable"), 1119 config.getSerialNumber()); 1120 } 1121 1122 1123 private Resource getPluginDirectory() { 1124 return config.getConfigDir().getRealResource("context/admin/plugin"); 1125 } 1126 1127 private Resource getContextDirectory() throws PageException { 1128 ConfigServer cs = config.getConfigServer(password); 1129 Resource dist = cs.getConfigDir().getRealResource("distribution"); 1130 dist.mkdirs(); 1131 return dist; 1132 } 1133 1134 private void doGetPluginDirectory() throws PageException { 1135 pageContext.setVariable( 1136 getString("admin",action,"returnVariable"), 1137 getPluginDirectory().getAbsolutePath()); 1138 } 1139 1140 private void doUpdatePlugin() throws PageException, IOException { 1141 String strSrc = getString("admin",action,"source"); 1142 Resource src = ResourceUtil.toResourceExisting(pageContext, strSrc); 1143 Resource srcDir = ResourceUtil.toResourceExisting(pageContext, "zip://"+src.getAbsolutePath()); 1144 String name=ResourceUtil.getName(src.getName()); 1145 if(!PluginFilter.doAccept(srcDir)) 1146 throw new ApplicationException("plugin ["+strSrc+"] is invalid, missing one of the following files [Action.cfc,language.xml] in root, existing files are ["+railo.runtime.type.util.ListUtil.arrayToList(srcDir.list(), ", ")+"]"); 1147 1148 Resource dir = getPluginDirectory(); 1149 Resource trgDir = dir.getRealResource(name); 1150 if(trgDir.exists()){ 1151 trgDir.remove(true); 1152 } 1153 1154 ResourceUtil.copyRecursive(srcDir, trgDir); 1155 store(); 1156 } 1157 1158 private void doUpdateLabel() throws PageException { 1159 if(config instanceof ConfigServer) { 1160 if(admin.updateLabel(getString("admin",action,"hash"),getString("admin",action,"label"))) { 1161 store(); 1162 adminSync.broadcast(attributes, config); 1163 } 1164 } 1165 } 1166 1167 private void doUpdateContext() throws PageException, IOException { 1168 String strSrc = getString("admin",action,"source"); 1169 String strRealpath = getString("admin",action,"destination"); 1170 Resource src = ResourceUtil.toResourceExisting(pageContext, strSrc); 1171 1172 ConfigServerImpl server = (ConfigServerImpl) config.getConfigServer(password); 1173 ConfigWeb[] webs = server.getConfigWebs(); 1174 ConfigWeb web; 1175 Resource trg,p; 1176 1177 for(int i=0;i<webs.length;i++){ 1178 web=webs[i]; 1179 trg=web.getConfigDir().getRealResource("context").getRealResource(strRealpath); 1180 1181 if(trg.exists()) trg.remove(true); 1182 p = trg.getParentResource(); 1183 if(!p.isDirectory())p.createDirectory(true); 1184 1185 src.copyTo(trg, false); 1186 } 1187 store(); 1188 } 1189 1190 1191 private void doRemoveContext() throws PageException, IOException { 1192 String strRealpath = getString("admin",action,"destination"); 1193 ConfigServerImpl server = (ConfigServerImpl) config; 1194 ConfigWeb[] webs = server.getConfigWebs(); 1195 1196 try { 1197 admin.removeContext(server, strRealpath, true); 1198 } 1199 catch (SAXException e) { 1200 throw Caster.toPageException(e); 1201 } 1202 1203 store(); 1204 } 1205 1206 private void doRemovePlugin() throws PageException, IOException { 1207 Resource dir = getPluginDirectory(); 1208 String name = getString("admin",action,"name"); 1209 Resource trgDir = dir.getRealResource(name); 1210 trgDir.remove(true); 1211 1212 store(); 1213 } 1214 1215 private void doGetPlugins() throws PageException { 1216 Resource dir = getPluginDirectory(); 1217 1218 String[] list = dir.list(new PluginFilter()); 1219 railo.runtime.type.Query qry= 1220 new QueryImpl( 1221 new Collection.Key[]{KeyConstants._name}, 1222 list.length,getString("admin",action,"returnVariable")); 1223 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 1224 1225 for(int i=0;i<list.length;i++) { 1226 int row=i+1; 1227 qry.setAtEL(KeyConstants._name,row,list[i]); 1228 } 1229 } 1230 1231 private void doStorageSet() throws PageException { 1232 try { 1233 admin.storageSet(config,getString("admin",action,"key"),getObject("admin", action, "value")); 1234 } 1235 catch (Exception e) { 1236 throw Caster.toPageException(e); 1237 } 1238 } 1239 1240 private void doStorageGet() throws PageException { 1241 try { 1242 pageContext.setVariable( 1243 getString("admin",action,"returnVariable"), 1244 admin.storageGet(config,getString("admin",action,"key"))); 1245 } 1246 catch (Exception e) { 1247 throw Caster.toPageException(e); 1248 } 1249 } 1250 1251 /** 1252 * @throws PageException 1253 * 1254 */ 1255 private void doGetDefaultPassword() throws PageException { 1256 String password = admin.getDefaultPassword(); 1257 if(password==null) password=""; 1258 1259 pageContext.setVariable( 1260 getString("admin",action,"returnVariable"), 1261 password); 1262 1263 } 1264 1265 /** 1266 * @throws PageException 1267 * 1268 */ 1269 private void doUpdateDefaultPassword() throws PageException { 1270 admin.updateDefaultPassword(getString("admin",action,"newPassword")); 1271 store(); 1272 } 1273 private void doRemoveDefaultPassword() throws PageException { 1274 admin.removeDefaultPassword(); 1275 store(); 1276 } 1277 1278 1279 /* * 1280 * @throws PageException 1281 * 1282 * / 1283 private void doUpdatePassword() throws PageException { 1284 try { 1285 ConfigWebAdmin.setPassword(config,password==null?null:Caster.toString(password),getString("admin",action,"newPassword")); 1286 } 1287 catch (Exception e) { 1288 throw Caster.toPageException(e); 1289 } 1290 //store(); 1291 }*/ 1292 1293 /** 1294 * @throws PageException 1295 * 1296 */ 1297 private void doGetDebug() throws PageException { 1298 Struct sct=new StructImpl(); 1299 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 1300 1301 sct.set(DEBUG,Caster.toBoolean(config.debug())); 1302 sct.set(KeyConstants._database,Caster.toBoolean(config.hasDebugOptions(ConfigImpl.DEBUG_DATABASE))); 1303 sct.set(KeyConstants._exception,Caster.toBoolean(config.hasDebugOptions(ConfigImpl.DEBUG_EXCEPTION))); 1304 sct.set("tracing",Caster.toBoolean(config.hasDebugOptions(ConfigImpl.DEBUG_TRACING))); 1305 sct.set("timer",Caster.toBoolean(config.hasDebugOptions(ConfigImpl.DEBUG_TIMER))); 1306 sct.set("implicitAccess",Caster.toBoolean(config.hasDebugOptions(ConfigImpl.DEBUG_IMPLICIT_ACCESS))); 1307 sct.set("queryUsage",Caster.toBoolean(config.hasDebugOptions(ConfigImpl.DEBUG_QUERY_USAGE))); 1308 } 1309 1310 private void doGetError() throws PageException { 1311 Struct sct=new StructImpl(); 1312 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 1313 //sct.set("errorTemplate",config.getErrorTemplate()); 1314 1315 Struct templates=new StructImpl(); 1316 Struct str=new StructImpl(); 1317 sct.set(TEMPLATES, templates); 1318 sct.set(STR, str); 1319 sct.set(DO_STATUS_CODE, Caster.toBoolean(config.getErrorStatusCode())); 1320 1321 // 500 1322 String template=config.getErrorTemplate(500); 1323 try { 1324 PageSource ps = ((PageContextImpl)pageContext).getPageSourceExisting(template); 1325 if(ps!=null) templates.set("500",ps.getDisplayPath()); 1326 else templates.set("500",""); 1327 } catch (PageException e) { 1328 templates.set("500",""); 1329 } 1330 str.set("500",template); 1331 1332 // 404 1333 template=config.getErrorTemplate(404); 1334 try { 1335 PageSource ps = ((PageContextImpl)pageContext).getPageSourceExisting(template); 1336 if(ps!=null) templates.set("404",ps.getDisplayPath()); 1337 else templates.set("404",""); 1338 } catch (PageException e) { 1339 templates.set("404",""); 1340 } 1341 str.set("404",template); 1342 1343 1344 1345 1346 1347 1348 } 1349 1350 /** 1351 * @throws PageException 1352 * 1353 */ 1354 private void doGetDebugData() throws PageException { 1355 pageContext.setVariable( 1356 getString("admin",action,"returnVariable"), 1357 pageContext.getDebugger().getDebuggingData(pageContext)); 1358 } 1359 private void doGetLoggedDebugData() throws PageException { 1360 1361 if(config instanceof ConfigServer) return ; 1362 1363 ConfigWebImpl cw=(ConfigWebImpl) config; 1364 1365 1366 pageContext.setVariable( 1367 getString("admin",action,"returnVariable"), 1368 cw.getDebuggerPool().getData(pageContext)); 1369 } 1370 1371 private void doGetInfo() throws PageException { 1372 Struct sct=new StructImpl(); 1373 pageContext.setVariable( 1374 getString("admin",action,"returnVariable"), 1375 sct); 1376 1377 1378 if(config instanceof ConfigWebImpl){ 1379 ConfigWebImpl cw=(ConfigWebImpl) config; 1380 sct.setEL(KeyConstants._label, cw.getLabel()); 1381 sct.setEL(HASH, cw.getHash()); 1382 sct.setEL(ROOT, cw.getRootDirectory().getAbsolutePath()); 1383 } 1384 1385 sct.setEL(KeyConstants._config, config 1386 .getConfigFile() 1387 .getAbsolutePath()); 1388 1389 // Servlets 1390 if(config instanceof ConfigServer) { 1391 ConfigServer cs=(ConfigServer) config; 1392 CFMLEngineImpl engine = (CFMLEngineImpl) cs.getCFMLEngine(); 1393 Struct srv=new StructImpl(),params; 1394 1395 1396 ServletConfig[] configs = engine.getServletConfigs(); 1397 ServletConfig sc; 1398 Enumeration e; 1399 String name,value; 1400 for(int i=0;i<configs.length;i++){ 1401 sc=configs[i]; 1402 e = sc.getInitParameterNames(); 1403 params=new StructImpl(); 1404 while(e.hasMoreElements()){ 1405 name=(String) e.nextElement(); 1406 value = sc.getInitParameter(name); 1407 params.set(name, value); 1408 } 1409 srv.set(sc.getServletName(), params); 1410 } 1411 sct.set("servlets", srv); 1412 } 1413 1414 } 1415 1416 /** 1417 * @throws PageException 1418 * 1419 */ 1420 private void doCreateSecurityManager() throws PageException { 1421 admin.createSecurityManager(password,getString("admin",action,"id")); 1422 store(); 1423 } 1424 1425 private void doRemoveSecurityManager() throws PageException { 1426 admin.removeSecurityManager(password,getString("admin",action,"id")); 1427 store(); 1428 } 1429 1430 1431 1432 private short fb(String key) throws PageException { 1433 return getBool("admin",action,key)?SecurityManager.VALUE_YES:SecurityManager.VALUE_NO; 1434 } 1435 private short fb2(String key) throws PageException { 1436 return SecurityManagerImpl.toShortAccessRWValue(getString("admin",action,key)); 1437 } 1438 1439 private void doUpdateDefaultSecurityManager() throws PageException { 1440 1441 admin.updateDefaultSecurity( 1442 fb("setting"), 1443 SecurityManagerImpl.toShortAccessValue(getString("admin",action,"file")), 1444 getFileAcces(), 1445 fb("direct_java_access"), 1446 fb("mail"), 1447 SecurityManagerImpl.toShortAccessValue(getString("admin",action,"datasource")), 1448 fb("mapping"), 1449 fb("remote"), 1450 fb("custom_tag"), 1451 fb("cfx_setting"), 1452 fb("cfx_usage"), 1453 fb("debugging"), 1454 fb("search"), 1455 fb("scheduled_task"), 1456 fb("tag_execute"), 1457 fb("tag_import"), 1458 fb("tag_object"), 1459 fb("tag_registry"), 1460 fb("cache"), 1461 fb("gateway"), 1462 fb("orm"), 1463 fb2("access_read"), 1464 fb2("access_write") 1465 ); 1466 store(); 1467 adminSync.broadcast(attributes, config); 1468 } 1469 1470 private Resource[] getFileAcces() throws PageException { 1471 Object value=attributes.get(FILE_ACCESS,null); 1472 if(value==null) return null; 1473 Array arr = Caster.toArray(value); 1474 List rtn = new ArrayList(); 1475 Iterator it = arr.valueIterator(); 1476 String path; 1477 Resource res; 1478 while(it.hasNext()){ 1479 path=Caster.toString(it.next()); 1480 if(StringUtil.isEmpty(path))continue; 1481 1482 res=config.getResource(path); 1483 if(!res.exists()) 1484 throw new ApplicationException("path ["+path+"] does not exist"); 1485 if(!res.isDirectory()) 1486 throw new ApplicationException("path ["+path+"] is not a directory"); 1487 rtn.add(res); 1488 } 1489 return (Resource[])rtn.toArray(new Resource[rtn.size()]); 1490 } 1491 1492 private void doUpdateSecurityManager() throws PageException { 1493 admin.updateSecurity( 1494 getString("admin",action,"id"), 1495 fb("setting"), 1496 SecurityManagerImpl.toShortAccessValue(getString("admin",action,"file")), 1497 getFileAcces(), 1498 fb("direct_java_access"), 1499 fb("mail"), 1500 SecurityManagerImpl.toShortAccessValue(getString("admin",action,"datasource")), 1501 fb("mapping"), 1502 fb("remote"), 1503 fb("custom_tag"), 1504 fb("cfx_setting"), 1505 fb("cfx_usage"), 1506 fb("debugging"), 1507 fb("search"), 1508 fb("scheduled_task"), 1509 fb("tag_execute"), 1510 fb("tag_import"), 1511 fb("tag_object"), 1512 fb("tag_registry"), 1513 fb("cache"), 1514 fb("gateway"), 1515 fb("orm"), 1516 fb2("access_read"), 1517 fb2("access_write") 1518 ); 1519 store(); 1520 } 1521 1522 1523 1524 /** 1525 * @throws PageException 1526 * 1527 */ 1528 private void doGetDefaultSecurityManager() throws PageException { 1529 SecurityManager dsm = config.getConfigServer(password).getDefaultSecurityManager(); 1530 _fillSecData(dsm); 1531 } 1532 1533 private void doGetSecurityManager() throws PageException { 1534 SecurityManager sm = config.getConfigServer(password).getSecurityManager(getString("admin",action,"id")); 1535 _fillSecData(sm); 1536 } 1537 1538 private void _fillSecData(SecurityManager sm) throws PageException { 1539 1540 Struct sct=new StructImpl(); 1541 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 1542 sct.set("cfx_setting",Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_CFX_SETTING)==SecurityManager.VALUE_YES)); 1543 sct.set("cfx_usage",Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_CFX_USAGE)==SecurityManager.VALUE_YES)); 1544 sct.set("custom_tag",Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_CUSTOM_TAG)==SecurityManager.VALUE_YES)); 1545 sct.set("datasource",_fillSecDataDS(sm.getAccess(SecurityManager.TYPE_DATASOURCE))); 1546 sct.set("debugging",Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_DEBUGGING)==SecurityManager.VALUE_YES)); 1547 sct.set("direct_java_access",Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_DIRECT_JAVA_ACCESS)==SecurityManager.VALUE_YES)); 1548 sct.set("mail",Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_MAIL)==SecurityManager.VALUE_YES)); 1549 sct.set("mapping",Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_MAPPING)==SecurityManager.VALUE_YES)); 1550 sct.set("remote",Caster.toBoolean(sm.getAccess(SecurityManagerImpl.TYPE_REMOTE)==SecurityManager.VALUE_YES)); 1551 sct.set("setting",Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_SETTING)==SecurityManager.VALUE_YES)); 1552 sct.set("search",Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_SEARCH)==SecurityManager.VALUE_YES)); 1553 sct.set("scheduled_task",Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_SCHEDULED_TASK)==SecurityManager.VALUE_YES)); 1554 sct.set("cache",Caster.toBoolean(sm.getAccess(SecurityManagerImpl.TYPE_CACHE)==SecurityManager.VALUE_YES)); 1555 sct.set("gateway",Caster.toBoolean(sm.getAccess(SecurityManagerImpl.TYPE_GATEWAY)==SecurityManager.VALUE_YES)); 1556 sct.set("orm",Caster.toBoolean(sm.getAccess(SecurityManagerImpl.TYPE_ORM)==SecurityManager.VALUE_YES)); 1557 1558 sct.set("tag_execute",Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_TAG_EXECUTE)==SecurityManager.VALUE_YES)); 1559 sct.set("tag_import",Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_TAG_IMPORT)==SecurityManager.VALUE_YES)); 1560 sct.set("tag_object",Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_TAG_OBJECT)==SecurityManager.VALUE_YES)); 1561 sct.set("tag_registry",Caster.toBoolean(sm.getAccess(SecurityManager.TYPE_TAG_REGISTRY)==SecurityManager.VALUE_YES)); 1562 sct.set("access_read",SecurityManagerImpl.toStringAccessRWValue(sm.getAccess(SecurityManager.TYPE_ACCESS_READ))); 1563 sct.set("access_write",SecurityManagerImpl.toStringAccessRWValue(sm.getAccess(SecurityManager.TYPE_ACCESS_WRITE))); 1564 short accessFile = sm.getAccess(SecurityManager.TYPE_FILE); 1565 String str = SecurityManagerImpl.toStringAccessValue(accessFile); 1566 if(str.equals("yes"))str="all"; 1567 sct.set("file",str); 1568 1569 Array arr=new ArrayImpl(); 1570 if(accessFile!=SecurityManager.VALUE_ALL){ 1571 Resource[] reses = ((SecurityManagerImpl)sm).getCustomFileAccess(); 1572 for(int i=0;i<reses.length;i++){ 1573 arr.appendEL(reses[i].getAbsolutePath()); 1574 } 1575 } 1576 sct.set("file_access",arr); 1577 1578 } 1579 1580 private Double _fillSecDataDS(short access) { 1581 switch(access) { 1582 case SecurityManager.VALUE_YES: return Caster.toDouble(-1); 1583 case SecurityManager.VALUE_NO: return Caster.toDouble(0); 1584 case SecurityManager.VALUE_1: return Caster.toDouble(1); 1585 case SecurityManager.VALUE_2: return Caster.toDouble(2); 1586 case SecurityManager.VALUE_3: return Caster.toDouble(3); 1587 case SecurityManager.VALUE_4: return Caster.toDouble(4); 1588 case SecurityManager.VALUE_5: return Caster.toDouble(5); 1589 case SecurityManager.VALUE_6: return Caster.toDouble(6); 1590 case SecurityManager.VALUE_7: return Caster.toDouble(7); 1591 case SecurityManager.VALUE_8: return Caster.toDouble(8); 1592 case SecurityManager.VALUE_9: return Caster.toDouble(9); 1593 case SecurityManager.VALUE_10: return Caster.toDouble(10); 1594 } 1595 return Caster.toDouble(-1); 1596 } 1597 1598 /** 1599 * @throws PageException 1600 * 1601 */ 1602 private void doUpdateDebug() throws PageException { 1603 1604 admin.updateDebug( 1605 Caster.toBoolean(getString("debug",""),null), 1606 Caster.toBoolean(getString("database",""),null), 1607 Caster.toBoolean(getString("exception",""),null), 1608 Caster.toBoolean(getString("tracing",""),null), 1609 Caster.toBoolean(getString("timer",""),null), 1610 Caster.toBoolean(getString("implicitAccess",""),null), 1611 Caster.toBoolean(getString("queryUsage",""),null) 1612 ); 1613 1614 1615 1616 admin.updateDebugTemplate(getString("admin",action,"debugTemplate")); 1617 store(); 1618 adminSync.broadcast(attributes, config); 1619 } 1620 1621 private void doGetDebugSetting() throws PageException { 1622 Struct sct=new StructImpl(); 1623 sct.set("maxLogs", Caster.toDouble(config.getDebugMaxRecordsLogged())); 1624 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 1625 1626 } 1627 private void doUpdateDebugSetting() throws PageException { 1628 String str = getString("admin",action,"maxLogs"); 1629 int maxLogs; 1630 if(StringUtil.isEmpty(str,true))maxLogs=-1; 1631 else 1632 maxLogs=Caster.toIntValue(str); 1633 admin.updateDebugSetting(maxLogs); 1634 store(); 1635 adminSync.broadcast(attributes, config); 1636 } 1637 1638 private void doUpdateDebugEntry() throws PageException { 1639 try { 1640 admin.updateDebugEntry( 1641 getString("admin","updateDebugEntry","debugtype"), 1642 getString("admin","updateDebugEntry","iprange"), 1643 getString("admin","updateDebugEntry","label"), 1644 getString("admin","updateDebugEntry","path"), 1645 getString("admin","updateDebugEntry","fullname"), 1646 getStruct("admin","updateDebugEntry","custom") 1647 ); 1648 } catch (IOException e) { 1649 throw Caster.toPageException(e); 1650 } 1651 1652 store(); 1653 adminSync.broadcast(attributes, config); 1654 } 1655 1656 private void doGetDebugEntry() throws PageException { 1657 DebugEntry[] entries = config.getDebugEntries(); 1658 1659 String rtn = getString("admin",action,"returnVariable"); 1660 railo.runtime.type.Query qry= 1661 new QueryImpl(new Collection.Key[]{KeyConstants._id,LABEL,IP_RANGE,READONLY,KeyConstants._type,CUSTOM},entries.length,rtn); 1662 pageContext.setVariable(rtn,qry); 1663 DebugEntry de; 1664 for(int i=0;i<entries.length;i++) { 1665 int row=i+1; 1666 de=entries[i]; 1667 qry.setAtEL(KeyConstants._id,row,de.getId()); 1668 qry.setAtEL(LABEL,row,de.getLabel()); 1669 qry.setAtEL(IP_RANGE,row,de.getIpRangeAsString()); 1670 qry.setAtEL(KeyConstants._type,row,de.getType()); 1671 qry.setAtEL(READONLY,row,Caster.toBoolean(de.isReadOnly())); 1672 qry.setAtEL(CUSTOM,row,de.getCustom()); 1673 } 1674 } 1675 1676 1677 private void doUpdateError() throws PageException { 1678 1679 admin.updateErrorTemplate(500,getString("admin",action,"template500")); 1680 admin.updateErrorTemplate(404,getString("admin",action,"template404")); 1681 admin.updateErrorStatusCode(getBoolObject("admin",action,"statuscode")); 1682 store(); 1683 adminSync.broadcast(attributes, config); 1684 } 1685 1686 /** 1687 * @throws PageException 1688 * 1689 */ 1690 private void doUpdateJavaCFX() throws PageException { 1691 String name=getString("admin",action,"name"); 1692 if(StringUtil.startsWithIgnoreCase(name,"cfx_"))name=name.substring(4); 1693 admin.updateJavaCFX( 1694 name, 1695 getString("admin",action,"class") 1696 ); 1697 store(); 1698 adminSync.broadcast(attributes, config); 1699 } 1700 1701 private void doVerifyJavaCFX() throws PageException { 1702 String name=getString("admin",action,"name"); 1703 admin.verifyJavaCFX( 1704 name, 1705 getString("admin",action,"class") 1706 ); 1707 } 1708 private void doVerifyCFX() throws PageException { 1709 String name=getString("admin",action,"name"); 1710 if(StringUtil.startsWithIgnoreCase(name,"cfx_"))name=name.substring(4); 1711 admin.verifyCFX(name); 1712 } 1713 1714 1715 private void doUpdateCPPCFX() throws PageException { 1716 String name=getString("admin",action,"name"); 1717 String procedure=getString("admin",action,"procedure"); 1718 String serverLibrary=getString("admin",action,"serverLibrary"); 1719 boolean keepAlive=getBool("admin",action,"keepAlive"); 1720 1721 1722 if(StringUtil.startsWithIgnoreCase(name,"cfx_"))name=name.substring(4); 1723 admin.updateCPPCFX(name,procedure,serverLibrary,keepAlive); 1724 store(); 1725 adminSync.broadcast(attributes, config); 1726 } 1727 1728 1729 1730 /** 1731 * @throws PageException 1732 * 1733 */ 1734 private void doRemoveCFX() throws PageException { 1735 admin.removeCFX( 1736 getString("admin",action,"name") 1737 ); 1738 store(); 1739 adminSync.broadcast(attributes, config); 1740 } 1741 private void doRemoveExtension() throws PageException { 1742 admin.removeExtension( 1743 getString("admin",action,"provider"), 1744 getString("admin",action,"id") 1745 ); 1746 store(); 1747 //adminSync.broadcast(attributes, config); 1748 } 1749 1750 1751 1752 /** 1753 * @throws PageException 1754 * 1755 */ 1756 private void doGetJavaCFXTags() throws PageException { 1757 Map map = config.getCFXTagPool().getClasses(); 1758 railo.runtime.type.Query qry=new QueryImpl(new Collection.Key[]{ 1759 KeyConstants._displayname, 1760 KeyConstants._sourcename, 1761 KeyConstants._readonly, 1762 KeyConstants._class, 1763 KeyConstants._name, 1764 KeyConstants._isvalid},0,"query"); 1765 Iterator it = map.keySet().iterator(); 1766 1767 int row=0; 1768 while(it.hasNext()) { 1769 CFXTagClass tag=(CFXTagClass) map.get(it.next()); 1770 if(tag instanceof JavaCFXTagClass) { 1771 row++; 1772 qry.addRow(1); 1773 JavaCFXTagClass jtag =(JavaCFXTagClass) tag; 1774 qry.setAt(KeyConstants._displayname,row,tag.getDisplayType()); 1775 qry.setAt(KeyConstants._sourcename,row,tag.getSourceName()); 1776 qry.setAt(KeyConstants._readonly,row,Caster.toBoolean(tag.isReadOnly())); 1777 qry.setAt(KeyConstants._isvalid,row,Caster.toBoolean(tag.isValid())); 1778 qry.setAt(KeyConstants._name,row,jtag.getName()); 1779 qry.setAt(KeyConstants._class,row,jtag.getStrClass()); 1780 } 1781 1782 } 1783 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 1784 } 1785 1786 private void doGetCPPCFXTags() throws PageException { 1787 Map map = config.getCFXTagPool().getClasses(); 1788 railo.runtime.type.Query qry=new QueryImpl(new Collection.Key[]{ 1789 KeyConstants._displayname, 1790 KeyConstants._sourcename, 1791 KeyConstants._readonly, 1792 PROCEDURE, 1793 KeyConstants._name, 1794 KeyConstants._isvalid, 1795 SERVER_LIBRARY, 1796 KEEP_ALIVE},0,"query"); 1797 Iterator it = map.keySet().iterator(); 1798 1799 int row=0; 1800 while(it.hasNext()) { 1801 CFXTagClass tag=(CFXTagClass) map.get(it.next()); 1802 if(tag instanceof CPPCFXTagClass) { 1803 row++; 1804 qry.addRow(1); 1805 CPPCFXTagClass ctag =(CPPCFXTagClass) tag; 1806 qry.setAt(KeyConstants._displayname,row,tag.getDisplayType()); 1807 qry.setAt(KeyConstants._sourcename,row,tag.getSourceName()); 1808 qry.setAt(KeyConstants._readonly,row,Caster.toBoolean(tag.isReadOnly())); 1809 qry.setAt(KeyConstants._isvalid,row,Caster.toBoolean(tag.isValid())); 1810 qry.setAt(KeyConstants._name,row,ctag.getName()); 1811 qry.setAt(PROCEDURE,row,ctag.getProcedure()); 1812 qry.setAt(SERVER_LIBRARY,row,ctag.getServerLibrary()); 1813 qry.setAt(KEEP_ALIVE,row,Caster.toBoolean(ctag.getKeepAlive())); 1814 } 1815 1816 } 1817 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 1818 } 1819 1820 /** 1821 * @throws PageException 1822 * 1823 */ 1824 private void doGetCFXTags() throws PageException { 1825 Map map = config.getCFXTagPool().getClasses(); 1826 railo.runtime.type.Query qry=new QueryImpl(new String[]{"displayname","sourcename","readonly","isvalid","name","procedure_class","keep_alive"},map.size(),"query"); 1827 Iterator it = map.keySet().iterator(); 1828 1829 int row=0; 1830 while(it.hasNext()) { 1831 row++; 1832 CFXTagClass tag=(CFXTagClass) map.get(it.next()); 1833 1834 qry.setAt("displayname",row,tag.getDisplayType()); 1835 qry.setAt("sourcename",row,tag.getSourceName()); 1836 qry.setAt("readonly",row,Caster.toBoolean(tag.isReadOnly())); 1837 qry.setAt("isvalid",row,Caster.toBoolean(tag.isValid())); 1838 1839 if(tag instanceof CPPCFXTagClass) { 1840 CPPCFXTagClass ctag =(CPPCFXTagClass) tag; 1841 qry.setAt(KeyConstants._name,row,ctag.getName()); 1842 qry.setAt("procedure_class",row,ctag.getProcedure()); 1843 qry.setAt("keepalive",row,Caster.toBoolean(ctag.getKeepAlive())); 1844 } 1845 else if(tag instanceof JavaCFXTagClass) { 1846 JavaCFXTagClass jtag =(JavaCFXTagClass) tag; 1847 qry.setAt(KeyConstants._name,row,jtag.getName()); 1848 qry.setAt("procedure_class",row,jtag.getStrClass()); 1849 } 1850 1851 } 1852 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 1853 } 1854 1855 1856 /** 1857 * @throws PageException 1858 */ 1859 private void doUpdateComponentMapping() throws PageException { 1860 admin.updateComponentMapping( 1861 getString("virtual",""), 1862 getString("physical",""), 1863 getString("archive",""), 1864 getString("primary","physical"), 1865 ConfigWebUtil.inspectTemplate(getString("inspect",""), ConfigImpl.INSPECT_UNDEFINED) 1866 ); 1867 store(); 1868 adminSync.broadcast(attributes, config); 1869 } 1870 1871 /** 1872 * @throws PageException 1873 * 1874 */ 1875 private void doRemoveComponentMapping() throws PageException { 1876 admin.removeComponentMapping( 1877 getString("admin",action,"virtual") 1878 ); 1879 store(); 1880 adminSync.broadcast(attributes, config); 1881 } 1882 1883 1884 1885 /** 1886 * @throws PageException 1887 */ 1888 private void doUpdateCustomTag() throws PageException { 1889 admin.updateCustomTag( 1890 getString("admin",action,"virtual"), 1891 getString("admin",action,"physical"), 1892 getString("admin",action,"archive"), 1893 getString("admin",action,"primary"), 1894 ConfigWebUtil.inspectTemplate(getString("inspect",""), ConfigImpl.INSPECT_UNDEFINED) 1895 ); 1896 store(); 1897 adminSync.broadcast(attributes, config); 1898 } 1899 1900 /** 1901 * @throws PageException 1902 * 1903 */ 1904 private void doRemoveCustomTag() throws PageException { 1905 admin.removeCustomTag( 1906 getString("admin",action,"virtual") 1907 ); 1908 store(); 1909 adminSync.broadcast(attributes, config); 1910 } 1911 1912 /** 1913 * @throws PageException 1914 * 1915 */ 1916 private void doGetCustomTagMappings() throws PageException { 1917 Mapping[] mappings = config.getCustomTagMappings(); 1918 railo.runtime.type.Query qry=new QueryImpl(new String[]{"archive","strarchive","physical","strphysical","virtual","hidden","physicalFirst","readonly","inspect"},mappings.length,"query"); 1919 1920 1921 for(int i=0;i<mappings.length;i++) { 1922 MappingImpl m=(MappingImpl) mappings[i]; 1923 int row=i+1; 1924 qry.setAt("archive",row,m.getArchive()); 1925 qry.setAt("strarchive",row,m.getStrArchive()); 1926 qry.setAt("physical",row,m.getPhysical()); 1927 qry.setAt("strphysical",row,m.getStrPhysical()); 1928 qry.setAt("virtual",row,m.getVirtual()); 1929 qry.setAt("hidden",row,Caster.toBoolean(m.isHidden())); 1930 qry.setAt("physicalFirst",row,Caster.toBoolean(m.isPhysicalFirst())); 1931 qry.setAt("readonly",row,Caster.toBoolean(m.isReadonly())); 1932 qry.setAt("inspect",row,ConfigWebUtil.inspectTemplate(m.getInspectTemplateRaw(), "")); 1933 } 1934 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 1935 } 1936 1937 private void doGetComponentMappings() throws PageException { 1938 Mapping[] mappings = config.getComponentMappings(); 1939 railo.runtime.type.Query qry=new QueryImpl(new String[]{"archive","strarchive","physical","strphysical","virtual","hidden","physicalFirst","readonly","inspect"},mappings.length,"query"); 1940 1941 1942 for(int i=0;i<mappings.length;i++) { 1943 MappingImpl m=(MappingImpl) mappings[i]; 1944 int row=i+1; 1945 qry.setAt("archive",row,m.getArchive()); 1946 qry.setAt("strarchive",row,m.getStrArchive()); 1947 qry.setAt("physical",row,m.getPhysical()); 1948 qry.setAt("strphysical",row,m.getStrPhysical()); 1949 qry.setAt("virtual",row,m.getVirtual()); 1950 qry.setAt("hidden",row,Caster.toBoolean(m.isHidden())); 1951 qry.setAt("physicalFirst",row,Caster.toBoolean(m.isPhysicalFirst())); 1952 qry.setAt("readonly",row,Caster.toBoolean(m.isReadonly())); 1953 qry.setAt("inspect",row,ConfigWebUtil.inspectTemplate(m.getInspectTemplateRaw(), "")); 1954 } 1955 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 1956 } 1957 1958 1959 /** 1960 * @throws PageException 1961 * 1962 */ 1963 private void doRemoveMapping() throws PageException { 1964 admin.removeMapping( 1965 getString("admin",action,"virtual") 1966 ); 1967 store(); 1968 adminSync.broadcast(attributes, config); 1969 } 1970 1971 /** 1972 * @throws PageException 1973 * 1974 */ 1975 private void doUpdateRestMapping() throws PageException { 1976 admin.updateRestMapping( 1977 getString("admin",action,"virtual"), 1978 getString("admin",action,"physical"), 1979 getBool("admin",action,"default") 1980 ); 1981 store(); 1982 adminSync.broadcast(attributes, config); 1983 1984 RestUtil.release(config.getRestMappings()); 1985 } 1986 1987 private void doRemoveRestMapping() throws PageException { 1988 admin.removeRestMapping( 1989 getString("admin",action,"virtual") 1990 ); 1991 store(); 1992 adminSync.broadcast(attributes, config); 1993 RestUtil.release(config.getRestMappings()); 1994 } 1995 1996 private void doUpdateMapping() throws PageException { 1997 admin.updateMapping( 1998 getString("admin",action,"virtual"), 1999 getString("admin",action,"physical"), 2000 getString("admin",action,"archive"), 2001 getString("admin",action,"primary"), 2002 ConfigWebUtil.inspectTemplate(getString("inspect",""), ConfigImpl.INSPECT_UNDEFINED), 2003 Caster.toBooleanValue(getString("toplevel","true")) 2004 ); 2005 store(); 2006 adminSync.broadcast(attributes, config); 2007 } 2008 2009 /** 2010 * @throws PageException 2011 * 2012 */ 2013 private void doGetMapping() throws PageException { 2014 2015 2016 Mapping[] mappings = config.getMappings(); 2017 Struct sct=new StructImpl(); 2018 String virtual=getString("admin",action,"virtual"); 2019 2020 for(int i=0;i<mappings.length;i++) { 2021 MappingImpl m=(MappingImpl) mappings[i]; 2022 if(!m.getVirtual().equals(virtual)) continue; 2023 2024 sct.set("archive",m.getArchive()); 2025 sct.set("strarchive",m.getStrArchive()); 2026 sct.set("physical",m.getPhysical()); 2027 sct.set("strphysical",m.getStrPhysical()); 2028 sct.set("virtual",m.getVirtual()); 2029 sct.set(KeyConstants._hidden,Caster.toBoolean(m.isHidden())); 2030 sct.set("physicalFirst",Caster.toBoolean(m.isPhysicalFirst())); 2031 sct.set("readonly",Caster.toBoolean(m.isReadonly())); 2032 sct.set("inspect",ConfigWebUtil.inspectTemplate(m.getInspectTemplateRaw(), "")); 2033 sct.set("toplevel",Caster.toBoolean(m.isTopLevel())); 2034 2035 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 2036 return; 2037 } 2038 throw new ApplicationException("there is no mapping with virtual ["+virtual+"]"); 2039 } 2040 2041 2042 private void doGetExtensionProviders() throws PageException { 2043 ExtensionProvider[] providers = config.getExtensionProviders(); 2044 railo.runtime.type.Query qry=new QueryImpl(new String[]{"url","isReadOnly"},providers.length,"query"); 2045 2046 ExtensionProvider provider; 2047 for(int i=0;i<providers.length;i++) { 2048 provider=providers[i]; 2049 int row=i+1; 2050 //qry.setAt("name",row,provider.getName()); 2051 qry.setAt(KeyConstants._url,row,provider.getUrlAsString()); 2052 qry.setAt("isReadOnly",row,Caster.toBoolean(provider.isReadOnly())); 2053 //qry.setAt("cacheTimeout",row,Caster.toDouble(provider.getCacheTimeout()/1000)); 2054 } 2055 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 2056 } 2057 2058 private void doGetExtensionInfo() throws PageException { 2059 Resource ed = config.getExtensionDirectory(); 2060 Struct sct=new StructImpl(); 2061 sct.set(KeyConstants._directory, ed.getPath()); 2062 sct.set(KeyConstants._enabled, Caster.toBoolean(config.isExtensionEnabled())); 2063 2064 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 2065 } 2066 2067 2068 2069 private void doGetExtensions() throws PageException { 2070 Extension[] extensions = config.getExtensions(); 2071 railo.runtime.type.Query qry=new QueryImpl(new String[]{ 2072 "type","provider","id","config","version","category","description","image","label","name", 2073 "author","codename","video","support","documentation","forum","mailinglist","network","created"},0,"query"); 2074 2075 String provider=getString("provider",null); 2076 String id=getString("id",null); 2077 Extension extension; 2078 String extProvider,extId; 2079 int row=0; 2080 for(int i=0;i<extensions.length;i++) { 2081 extension=extensions[i]; 2082 if(!extension.getType().equalsIgnoreCase("all") && toType(extension.getType(), false)!=type) 2083 continue; 2084 2085 extProvider=extension.getProvider(); 2086 extId=extension.getId(); 2087 if(provider!=null && !provider.equalsIgnoreCase(extProvider)) continue; 2088 if(id!=null && !id.equalsIgnoreCase(extId)) continue; 2089 2090 qry.addRow(); 2091 row++; 2092 qry.setAt("provider",row,extProvider); 2093 qry.setAt(KeyConstants._id,row,extId); 2094 qry.setAt(KeyConstants._config,row,extension.getConfig(pageContext)); 2095 qry.setAt(KeyConstants._version,row,extension.getVersion()); 2096 2097 qry.setAt("category",row,extension.getCategory()); 2098 qry.setAt(KeyConstants._description,row,extension.getDescription()); 2099 qry.setAt("image",row,extension.getImage()); 2100 qry.setAt(KeyConstants._label,row,extension.getLabel()); 2101 qry.setAt(KeyConstants._name,row,extension.getName()); 2102 2103 qry.setAt(KeyConstants._author,row,extension.getAuthor()); 2104 qry.setAt("codename",row,extension.getCodename()); 2105 qry.setAt("video",row,extension.getVideo()); 2106 qry.setAt("support",row,extension.getSupport()); 2107 qry.setAt("documentation",row,extension.getDocumentation()); 2108 qry.setAt("forum",row,extension.getForum()); 2109 qry.setAt("mailinglist",row,extension.getMailinglist()); 2110 qry.setAt("network",row,extension.getNetwork()); 2111 qry.setAt(KeyConstants._created,row,extension.getCreated()); 2112 qry.setAt(KeyConstants._type,row,extension.getType()); 2113 2114 } 2115 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 2116 } 2117 2118 2119 2120 2121 private void doGetMappings() throws PageException { 2122 2123 2124 Mapping[] mappings = config.getMappings(); 2125 railo.runtime.type.Query qry=new QueryImpl(new String[]{"archive","strarchive","physical","strphysical","virtual","hidden","physicalFirst","readonly","inspect","toplevel"},mappings.length,"query"); 2126 2127 2128 for(int i=0;i<mappings.length;i++) { 2129 MappingImpl m=(MappingImpl) mappings[i]; 2130 int row=i+1; 2131 qry.setAt("archive",row,m.getArchive()); 2132 qry.setAt("strarchive",row,m.getStrArchive()); 2133 qry.setAt("physical",row,m.getPhysical()); 2134 qry.setAt("strphysical",row,m.getStrPhysical()); 2135 qry.setAt("virtual",row,m.getVirtual()); 2136 qry.setAt("hidden",row,Caster.toBoolean(m.isHidden())); 2137 qry.setAt("physicalFirst",row,Caster.toBoolean(m.isPhysicalFirst())); 2138 qry.setAt("readonly",row,Caster.toBoolean(m.isReadonly())); 2139 qry.setAt("inspect",row,ConfigWebUtil.inspectTemplate(m.getInspectTemplateRaw(), "")); 2140 qry.setAt("toplevel",row,Caster.toBoolean(m.isTopLevel())); 2141 } 2142 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 2143 } 2144 2145 private void doGetRestMappings() throws PageException { 2146 2147 2148 railo.runtime.rest.Mapping[] mappings = config.getRestMappings(); 2149 railo.runtime.type.Query qry=new QueryImpl(new String[]{"physical","strphysical","virtual","hidden","readonly","default"},mappings.length,"query"); 2150 2151 railo.runtime.rest.Mapping m; 2152 for(int i=0;i<mappings.length;i++) { 2153 m=mappings[i]; 2154 int row=i+1; 2155 qry.setAt("physical",row,m.getPhysical()); 2156 qry.setAt("strphysical",row,m.getStrPhysical()); 2157 qry.setAt("virtual",row,m.getVirtual()); 2158 qry.setAt("hidden",row,Caster.toBoolean(m.isHidden())); 2159 qry.setAt("readonly",row,Caster.toBoolean(m.isReadonly())); 2160 qry.setAt("default",row,Caster.toBoolean(m.isDefault())); 2161 } 2162 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 2163 } 2164 2165 private void doGetRestSettings() throws PageException { 2166 Struct sct=new StructImpl(); 2167 sct.set(KeyConstants._list, Caster.toBoolean(config.getRestList())); 2168 //sct.set(KeyImpl.init("allowChanges"), Caster.toBoolean(config.getRestAllowChanges())); 2169 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 2170 2171 } 2172 2173 private void doGetResourceProviders() throws PageException { 2174 2175 pageContext.setVariable(getString("admin",action,"returnVariable"),admin.getResourceProviders()); 2176 } 2177 2178 private void doGetClusterClass() throws PageException { 2179 pageContext.setVariable(getString("admin",action,"returnVariable"),config.getClusterClass().getName()); 2180 } 2181 2182 2183 private void doUpdateClusterClass() throws PageException { 2184 admin.updateClusterClass(getString("admin",action,"class")); 2185 store(); 2186 } 2187 2188 private void doUpdateAdminSyncClass() throws PageException { 2189 admin.updateAdminSyncClass(getString("admin",action,"class")); 2190 store(); 2191 } 2192 2193 private void doGetAdminSyncClass() throws PageException { 2194 pageContext.setVariable(getString("admin",action,"returnVariable"),config.getAdminSyncClass().getName()); 2195 } 2196 2197 private void doUpdateVideoExecuterClass() throws PageException { 2198 admin.updateVideoExecuterClass(getString("admin",action,"class")); 2199 store(); 2200 } 2201 2202 private void doGetVideoExecuterClass() throws PageException { 2203 pageContext.setVariable(getString("admin",action,"returnVariable"),config.getVideoExecuterClass().getName()); 2204 } 2205 2206 2207 2208 /** 2209 * @throws PageException 2210 * 2211 */ 2212 private void doRemoveMailServer() throws PageException { 2213 admin.removeMailServer(getString("admin",action,"hostname")); 2214 store(); 2215 adminSync.broadcast(attributes, config); 2216 } 2217 2218 /** 2219 * @throws PageException 2220 * 2221 */ 2222 private void doUpdateMailServer() throws PageException { 2223 2224 admin.updateMailServer( 2225 getString("admin",action,"hostname"), 2226 getString("admin",action,"dbusername"), 2227 getString("admin",action,"dbpassword"), 2228 Caster.toIntValue(getString("admin",action,"port")), 2229 getBoolV("tls", false), 2230 getBoolV("ssl", false) 2231 ); 2232 store(); 2233 adminSync.broadcast(attributes, config); 2234 } 2235 2236 /** 2237 * @throws PageException 2238 * 2239 */ 2240 private void doUpdateMailSetting() throws PageException { 2241 admin.setMailLog(getString("admin",action,"logfile"),getString("loglevel","ERROR")); 2242 2243 //print.ln("----------------------------------"); 2244 admin.setMailSpoolEnable(getBoolObject("admin",action,"spoolenable")); 2245 // spool intervall 2246 String str=getString("admin",action,"spoolinterval"); 2247 Integer i=null; 2248 if(!StringUtil.isEmpty(str))i=Caster.toInteger(str); 2249 admin.setMailSpoolInterval(i); 2250 2251 // timeout 2252 str=getString("admin",action,"timeout"); 2253 i=null; 2254 if(!StringUtil.isEmpty(str))i=Caster.toInteger(str); 2255 admin.setMailTimeout(i); 2256 2257 admin.setMailDefaultCharset(getString("admin", action, "defaultencoding")); 2258 store(); 2259 adminSync.broadcast(attributes, config); 2260 } 2261 2262 2263 2264 private void listPatches() throws PageException { 2265 try { 2266 2267 pageContext.setVariable(getString("admin",action,"returnVariable"),Caster.toArray(((ConfigServerImpl)config).getInstalledPatches())); 2268 } catch (Exception e) { 2269 throw Caster.toPageException(e); 2270 } 2271 } 2272 2273 private void needNewJars() throws PageException { 2274 boolean needNewJars = JarLoader.changed(pageContext.getConfig(), UPDATE_JARS); 2275 2276 try { 2277 pageContext.setVariable(getString("admin",action,"returnVariable"),needNewJars); 2278 } 2279 catch (Exception e) { 2280 throw Caster.toPageException(e); 2281 } 2282 } 2283 2284 private void doUpdateJars() throws PageException { 2285 try { 2286 JarLoader.download(pageContext, UPDATE_JARS); 2287 } catch (IOException e) { 2288 throw Caster.toPageException(e); 2289 } 2290 2291 } 2292 2293 2294 2295 private void doGetMailServers() throws PageException { 2296 2297 2298 2299 Server[] servers = config.getMailServers(); 2300 railo.runtime.type.Query qry=new QueryImpl(new String[]{"hostname","password","username","port","authentication","readonly","tls","ssl"},servers.length,"query"); 2301 2302 2303 for(int i=0;i<servers.length;i++) { 2304 Server s= servers[i]; 2305 int row=i+1; 2306 qry.setAt("hostname",row,s.getHostName()); 2307 qry.setAt("password",row,s.isReadOnly()?"":s.getPassword()); 2308 qry.setAt("username",row,s.isReadOnly()?"":s.getUsername()); 2309 qry.setAt("port",row,Caster.toInteger(s.getPort())); 2310 qry.setAt("readonly",row,Caster.toBoolean(s.isReadOnly())); 2311 qry.setAt("authentication",row,Caster.toBoolean(s.hasAuthentication())); 2312 if(s instanceof ServerImpl) { 2313 ServerImpl si = (ServerImpl)s; 2314 qry.setAt("ssl",row,Caster.toBoolean(si.isSSL())); 2315 qry.setAt("tls",row,Caster.toBoolean(si.isTLS())); 2316 } 2317 } 2318 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 2319 } 2320 2321 private void doGetRunningThreads() throws PageException { 2322 railo.runtime.type.Query qry=new QueryImpl(new String[]{"Id","Start","Timeout","ThreadType","StackTrace","TagContext", 2323 "Label","RootPath","ConfigFile","URL"},0,"query"); 2324 2325 2326 if(type==TYPE_WEB){ 2327 fillGetRunningThreads(qry,pageContext.getConfig()); 2328 } 2329 else { 2330 ConfigServer cs = pageContext.getConfig().getConfigServer(password); 2331 ConfigWeb[] webs = cs.getConfigWebs(); 2332 for(int i=0;i<webs.length;i++){ 2333 fillGetRunningThreads(qry,webs[i]); 2334 } 2335 } 2336 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 2337 } 2338 2339 private static void fillGetRunningThreads(railo.runtime.type.Query qry, ConfigWeb configWeb) throws PageException { 2340 CFMLFactoryImpl factory = ((CFMLFactoryImpl)configWeb.getFactory()); 2341 Struct pcs =factory.getRunningPageContextes(); 2342 Iterator it = pcs.keyIterator(); 2343 PageContextImpl pc; 2344 Collection.Key key; 2345 int row=0; 2346 while(it.hasNext()) { 2347 key=KeyImpl.toKey(it.next(),null); 2348 pc=(PageContextImpl) pcs.get(key,null); 2349 qry.addRow(); 2350 row++; 2351 StackTraceElement[] st = pc.getThread().getStackTrace(); 2352 configWeb.getConfigDir(); 2353 configWeb.getId(); 2354 configWeb.getConfigDir(); 2355 qry.setAt("Id",row,new Double(pc.getId())); 2356 qry.setAt("Start",row,new DateTimeImpl(pc.getStartTime(),false)); 2357 qry.setAt("Timeout",row,new Double(pc.getRequestTimeout()/1000)); 2358 qry.setAt("ThreadType",row,pc.getParentPageContext()==null?"main":"child"); 2359 qry.setAt("StackTrace",row,toString(st)); 2360 qry.setAt("TagContext",row,PageExceptionImpl.getTagContext(pc.getConfig(), st)); 2361 2362 qry.setAt("label",row,factory.getLabel()); 2363 qry.setAt("RootPath",row,ReqRspUtil.getRootPath(((ConfigWebImpl)configWeb).getServletContext())); 2364 qry.setAt("ConfigFile",row,configWeb.getConfigFile().getAbsolutePath()); 2365 if(factory.getURL()!=null)qry.setAt("url",row,factory.getURL().toExternalForm()); 2366 2367 } 2368 2369 } 2370 2371 private static String toString(StackTraceElement[] traces) { 2372 StackTraceElement trace; 2373 StringBuilder sb=new StringBuilder( traces.length * 32 ); 2374 for(int i=0;i<traces.length;i++){ 2375 trace=traces[i]; 2376 sb.append("\tat "); 2377 sb.append(trace.toString()); 2378 sb.append(':'); 2379 sb.append(trace.getLineNumber()); 2380 sb.append(SystemUtil.getOSSpecificLineSeparator()); 2381 } 2382 return sb.toString(); 2383 } 2384 2385 2386 /** 2387 * @throws PageException 2388 * 2389 */ 2390 private void doGetMailSetting() throws PageException { 2391 Struct sct=new StructImpl(); 2392 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 2393 2394 LogAndSource ls=config.getMailLogger(); 2395 railo.commons.io.log.Log log=ls.getLog(); 2396 String logFile=""; 2397 //String logLevel=""; 2398 if(log instanceof LogResource)logFile=((LogResource)log).getResource().toString(); 2399 String logLevel=LogUtil.toStringType(log.getLogLevel(),"ERROR"); 2400 sct.set("strlogfile",ls.getSource()); 2401 sct.set("logfile",logFile); 2402 sct.set("loglevel",logLevel); 2403 2404 sct.set("spoolEnable",Caster.toBoolean(config.isMailSpoolEnable())); 2405 sct.set("spoolInterval",Caster.toInteger(config.getMailSpoolInterval())); 2406 sct.set("timeout",Caster.toInteger(config.getMailTimeout())); 2407 sct.set("defaultencoding", config.getMailDefaultEncoding()); 2408 2409 } 2410 2411 /** 2412 * @throws PageException 2413 * 2414 */ 2415 private void doGetTLDs() throws PageException { 2416 railo.runtime.type.Query qry=new QueryImpl( 2417 new String[]{"displayname","namespace","namespaceseparator","shortname","type","description","uri","elclass","source"}, 2418 new String[]{"varchar","varchar","varchar","varchar","varchar","varchar","varchar","varchar","varchar"}, 2419 0,"tlds"); 2420 2421 2422 TagLib[] libs = config.getTLDs(); 2423 for(int i=0;i<libs.length;i++) { 2424 qry.addRow(); 2425 qry.setAt("displayname", i+1, libs[i].getDisplayName()); 2426 qry.setAt("namespace", i+1, libs[i].getNameSpace()); 2427 qry.setAt("namespaceseparator", i+1, libs[i].getNameSpaceSeparator()); 2428 qry.setAt("shortname", i+1, libs[i].getShortName()); 2429 qry.setAt("type", i+1, libs[i].getType()); 2430 qry.setAt("description", i+1, libs[i].getDescription()); 2431 qry.setAt("uri", i+1, Caster.toString(libs[i].getUri())); 2432 qry.setAt("elclass", i+1, libs[i].getELClass()); 2433 qry.setAt("source", i+1, StringUtil.emptyIfNull(libs[i].getSource())); 2434 } 2435 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 2436 } 2437 2438 /** 2439 * @throws PageException 2440 * 2441 */ 2442 private void doGetFLDs() throws PageException { 2443 railo.runtime.type.Query qry=new QueryImpl( 2444 new String[]{"displayname","namespace","namespaceseparator","shortname","description","uri","source"}, 2445 new String[]{"varchar","varchar","varchar","varchar","varchar","varchar","varchar"}, 2446 0,"tlds"); 2447 2448 2449 FunctionLib[] libs = config.getFLDs(); 2450 for(int i=0;i<libs.length;i++) { 2451 qry.addRow(); 2452 qry.setAt("displayname", i+1, libs[i].getDisplayName()); 2453 qry.setAt("namespace", i+1, "");// TODO support for namespace 2454 qry.setAt("namespaceseparator", i+1, ""); 2455 qry.setAt("shortname", i+1, libs[i].getShortName()); 2456 qry.setAt("description", i+1, libs[i].getDescription()); 2457 qry.setAt("uri", i+1, Caster.toString(libs[i].getUri())); 2458 qry.setAt("source", i+1, StringUtil.emptyIfNull(libs[i].getSource())); 2459 } 2460 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 2461 } 2462 2463 private void doGetRemoteClientUsage() throws PageException { 2464 railo.runtime.type.Query qry=new QueryImpl( 2465 new String[]{"code","displayname"}, 2466 new String[]{"varchar","varchar"}, 2467 0,"usage"); 2468 Struct usages = config.getRemoteClientUsage(); 2469 //Key[] keys = usages.keys(); 2470 Iterator<Entry<Key, Object>> it = usages.entryIterator(); 2471 Entry<Key, Object> e; 2472 int i=-1; 2473 while(it.hasNext()) { 2474 i++; 2475 e = it.next(); 2476 qry.addRow(); 2477 qry.setAt(KeyConstants._code, i+1, e.getKey().getString()); 2478 qry.setAt(KeyConstants._displayname, i+1, e.getValue()); 2479 //qry.setAt("description", i+1, usages[i].getDescription()); 2480 } 2481 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 2482 } 2483 2484 private void doHasRemoteClientUsage() throws PageException { 2485 2486 Struct usages = config.getRemoteClientUsage(); 2487 pageContext.setVariable(getString("admin",action,"returnVariable"),usages.isEmpty()?Boolean.FALSE:Boolean.TRUE); 2488 } 2489 2490 2491 2492 private void doGetJars() throws PageException { 2493 Resource lib = config.getConfigDir().getRealResource("lib"); 2494 railo.runtime.type.Query qry=new QueryImpl(new String[]{"name","source"},new String[]{"varchar","varchar"},0,"jars"); 2495 2496 if(lib.isDirectory()){ 2497 Resource[] children = lib.listResources(new ExtensionResourceFilter(new String[]{".jar",".zip"},false,true)); 2498 for(int i=0;i<children.length;i++){ 2499 qry.addRow(); 2500 qry.setAt("name", i+1, children[i].getName()); 2501 qry.setAt("source", i+1, children[i].getAbsolutePath()); 2502 } 2503 } 2504 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 2505 } 2506 2507 /** 2508 * @throws PageException 2509 * 2510 */ 2511 private void doUpdateDatasource() throws PageException { 2512 int allow= 2513 (getBoolV("allowed_select",false)?DataSource.ALLOW_SELECT:0)+ 2514 (getBoolV("allowed_insert",false)?DataSource.ALLOW_INSERT:0)+ 2515 (getBoolV("allowed_update",false)?DataSource.ALLOW_UPDATE:0)+ 2516 (getBoolV("allowed_delete",false)?DataSource.ALLOW_DELETE:0)+ 2517 (getBoolV("allowed_alter",false)?DataSource.ALLOW_ALTER:0)+ 2518 (getBoolV("allowed_drop",false)?DataSource.ALLOW_DROP:0)+ 2519 (getBoolV("allowed_revoke",false)?DataSource.ALLOW_REVOKE:0)+ 2520 (getBoolV("allowed_grant",false)?DataSource.ALLOW_GRANT:0)+ 2521 (getBoolV("allowed_create",false)?DataSource.ALLOW_CREATE:0); 2522 if(allow==0)allow=DataSource.ALLOW_ALL; 2523 String classname=getString("admin",action,"classname"); 2524 /*Class clazz=null; 2525 try { 2526 clazz = ClassUtil.loadClass(config.getClassLoader(),classname);//Class.orName(classname); 2527 } 2528 catch (ClassException e) { 2529 throw new DatabaseException("can't find class ["+classname+"] for jdbc driver, check if driver (jar file) is inside lib folder",e.getMessage(),null,null,null); 2530 }*/ 2531 2532 String dsn=getString("admin",action,"dsn"); 2533 String name=getString("admin",action,"name"); 2534 String newName=getString("admin",action,"newName"); 2535 String username=getString("admin",action,"dbusername"); 2536 String password=getString("admin",action,"dbpassword"); 2537 String host=getString("host",""); 2538 String timezone=getString("timezone",""); 2539 String database=getString("database",""); 2540 int port=getInt("port",-1); 2541 int connLimit=getInt("connectionLimit",-1); 2542 int connTimeout=getInt("connectionTimeout",-1); 2543 long metaCacheTimeout=getLong("metaCacheTimeout",60000); 2544 boolean blob=getBoolV("blob",false); 2545 boolean clob=getBoolV("clob",false); 2546 boolean validate=getBoolV("validate",false); 2547 boolean storage=getBoolV("storage",false); 2548 boolean verify=getBoolV("verify",true); 2549 Struct custom=getStruct("custom",new StructImpl()); 2550 2551 //config.getDatasourceConnectionPool().remove(name); 2552 DataSource ds=null; 2553 try { 2554 ds = new DataSourceImpl(name,classname,host,dsn,database,port,username,password,connLimit,connTimeout,metaCacheTimeout,blob,clob,allow,custom,false,validate,storage,null); 2555 } catch (ClassException e) { 2556 throw new DatabaseException("can't find class ["+classname+"] for jdbc driver, check if driver (jar file) is inside lib folder",e.getMessage(),null,null,null); 2557 } 2558 2559 if(verify)_doVerifyDatasource(classname,ds.getDsnTranslated(),username,password); 2560 //print.out("limit:"+connLimit); 2561 admin.updateDataSource( 2562 name, 2563 newName, 2564 classname, 2565 dsn, 2566 username, 2567 password, 2568 host, 2569 database, 2570 port, 2571 connLimit, 2572 connTimeout, 2573 metaCacheTimeout, 2574 blob, 2575 clob, 2576 allow, 2577 validate, 2578 storage, 2579 timezone, 2580 custom 2581 2582 ); 2583 store(); 2584 adminSync.broadcast(attributes, config); 2585 } 2586 2587 private void doUpdateCacheConnection() throws PageException { 2588 admin.updateCacheConnection( 2589 getString("admin",action,"name"), 2590 getString("admin",action,"class"), 2591 toCacheConstant("default"), 2592 getStruct("admin", action, "custom"), 2593 getBoolV("readOnly", false), 2594 getBoolV("storage", false) 2595 2596 ); 2597 store(); 2598 adminSync.broadcast(attributes, config); 2599 } 2600 2601 private void doUpdateGatewayEntry() throws PageException { 2602 String strStartupMode=getString("admin",action,"startupMode"); 2603 int startup=GatewayEntryImpl.toStartup(strStartupMode,-1); 2604 if(startup==-1) 2605 throw new ApplicationException("invalid startup mode ["+strStartupMode+"], valid values are [automatic,manual,disabled]"); 2606 //print.out("doUpdateGatewayEntry"); 2607 admin.updateGatewayEntry( 2608 getString("admin",action,"id"), 2609 getString("admin",action,"class"), 2610 getString("admin",action,"cfcPath"), 2611 getString("admin",action,"listenerCfcPath"), 2612 startup, 2613 getStruct("admin", action, "custom"), 2614 getBoolV("readOnly", false) 2615 2616 ); 2617 store(); 2618 adminSync.broadcast(attributes, config); 2619 } 2620 2621 private int toCacheConstant(String name) throws ApplicationException { 2622 String def = getString(name, null); 2623 if(StringUtil.isEmpty(def)) return ConfigImpl.CACHE_DEFAULT_NONE; 2624 def=def.trim().toLowerCase(); 2625 2626 if(def.equals("object")) return ConfigImpl.CACHE_DEFAULT_OBJECT; 2627 if(def.equals("template")) return ConfigImpl.CACHE_DEFAULT_TEMPLATE; 2628 if(def.equals("query")) return ConfigImpl.CACHE_DEFAULT_QUERY; 2629 if(def.equals("resource")) return ConfigImpl.CACHE_DEFAULT_RESOURCE; 2630 if(def.equals("function")) return ConfigImpl.CACHE_DEFAULT_FUNCTION; 2631 2632 throw new ApplicationException("invalid default type ["+def+"], valid default types are [object,template,query,resource,function]"); 2633 } 2634 2635 private void doUpdateCacheDefaultConnection() throws PageException { 2636 admin.updateCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_OBJECT,getString("admin",action,"object")); 2637 admin.updateCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_TEMPLATE,getString("admin",action,"template")); 2638 admin.updateCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_QUERY,getString("admin",action,"query")); 2639 admin.updateCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_RESOURCE,getString("admin",action,"resource")); 2640 admin.updateCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_FUNCTION,getString("admin",action,"function")); 2641 store(); 2642 adminSync.broadcast(attributes, config); 2643 } 2644 2645 private void doRemoveCacheDefaultConnection() throws PageException { 2646 admin.removeCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_OBJECT); 2647 admin.removeCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_TEMPLATE); 2648 admin.removeCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_QUERY); 2649 admin.removeCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_RESOURCE); 2650 admin.removeCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_FUNCTION); 2651 store(); 2652 adminSync.broadcast(attributes, config); 2653 } 2654 2655 private void doRemoveResourceProvider() throws PageException { 2656 String classname=getString("admin",action,"class"); 2657 2658 Class clazz=null; 2659 try { 2660 clazz = ClassUtil.loadClass(config.getClassLoader(),classname); 2661 } catch (ClassException e) { 2662 throw Caster.toPageException(e); 2663 } 2664 2665 admin.removeResourceProvider(clazz); 2666 2667 store(); 2668 adminSync.broadcast(attributes, config); 2669 } 2670 2671 2672 private void doUpdateResourceProvider() throws PageException { 2673 String classname=getString("admin",action,"class"); 2674 2675 Class clazz=null; 2676 try { 2677 clazz = ClassUtil.loadClass(config.getClassLoader(),classname); 2678 } catch (ClassException e) { 2679 throw Caster.toPageException(e); 2680 } 2681 String scheme=getString("admin",action,"scheme"); 2682 2683 Struct sctArguments = getStruct("arguments", null); 2684 if(sctArguments!=null) { 2685 2686 admin.updateResourceProvider(scheme,clazz,sctArguments); 2687 } 2688 else { 2689 String strArguments=getString("admin",action,"arguments"); 2690 admin.updateResourceProvider(scheme,clazz,strArguments); 2691 } 2692 2693 2694 2695 //admin.updateResourceProvider(scheme,clazz,arguments); 2696 store(); 2697 adminSync.broadcast(attributes, config); 2698 } 2699 2700 private void doUpdateDefaultResourceProvider() throws PageException { 2701 String classname=getString("admin",action,"class"); 2702 Class clazz=null; 2703 try { 2704 clazz = ClassUtil.loadClass(config.getClassLoader(),classname); 2705 } catch (ClassException e) { 2706 throw Caster.toPageException(e); 2707 } 2708 String arguments=getString("admin",action,"arguments"); 2709 2710 admin.updateDefaultResourceProvider(clazz,arguments); 2711 store(); 2712 adminSync.broadcast(attributes, config); 2713 } 2714 2715 2716 2717 private void doVerifyMailServer() throws PageException { 2718 _doVerifyMailServer( 2719 getString("admin",action,"hostname"), 2720 getInt("admin",action,"port"), 2721 getString("admin",action,"mailusername"), 2722 getString("admin",action,"mailpassword") 2723 ); 2724 } 2725 2726 private void _doVerifyMailServer(String host, int port, String user, String pass) throws PageException { 2727 try { 2728 SMTPVerifier.verify(host,user,pass,port); 2729 } catch (SMTPException e) { 2730 throw Caster.toPageException(e); 2731 } 2732 } 2733 2734 /** 2735 * @throws PageException 2736 * 2737 */ 2738 private void doVerifyDatasource() throws PageException { 2739 String classname=(String) attributes.get("classname",null); 2740 String dsn=(String) attributes.get("dsn",null); 2741 if(classname!=null && dsn!=null) { 2742 _doVerifyDatasource(classname,dsn, 2743 getString("admin",action,"dbusername"), 2744 getString("admin",action,"dbpassword")); 2745 } 2746 else { 2747 _doVerifyDatasource( 2748 getString("admin",action,"name"), 2749 getString("admin",action,"dbusername"), 2750 getString("admin",action,"dbpassword")); 2751 } 2752 } 2753 2754 private void doVerifyRemoteClient() throws PageException { 2755 // SNSN 2756 /*SerialNumber sn = config.getSerialNumber(); 2757 if(sn.getVersion()==SerialNumber.VERSION_COMMUNITY) 2758 throw new SecurityException("can not verify remote client with "+sn.getStringVersion()+" version of railo"); 2759 */ 2760 ProxyData pd=null; 2761 String proxyServer=getString("proxyServer",null); 2762 if(!StringUtil.isEmpty(proxyServer)) { 2763 String proxyUsername=getString("proxyUsername",null); 2764 String proxyPassword=getString("proxyPassword",null); 2765 int proxyPort = getInt("proxyPort",-1); 2766 pd=new ProxyDataImpl(); 2767 pd.setServer(proxyServer); 2768 if(!StringUtil.isEmpty(proxyUsername))pd.setUsername(proxyUsername); 2769 if(!StringUtil.isEmpty(proxyPassword))pd.setPassword(proxyPassword); 2770 if(proxyPort!=-1)pd.setPort(proxyPort); 2771 } 2772 RemoteClient client = new RemoteClientImpl( 2773 getString("admin",action,"label"), 2774 type==TYPE_WEB?"web":"server", 2775 getString("admin",action,"url"), 2776 getString("serverUsername",null), 2777 getString("serverPassword",null), 2778 getString("admin",action,"adminPassword"), 2779 pd, 2780 getString("admin",action,"securityKey"), 2781 getString("admin",action,"usage") 2782 2783 ); 2784 2785 Struct attrColl=new StructImpl(); 2786 attrColl.setEL("action", "connect"); 2787 try { 2788 new RemoteClientTask(null,client,attrColl,getCallerId(),"synchronisation").execute(config); 2789 } 2790 catch (Throwable t) { 2791 throw Caster.toPageException(t); 2792 } 2793 } 2794 2795 2796 private void _doVerifyDatasource(String classname, String dsn, String username, String password) throws PageException { 2797 try { 2798 Class clazz=null; 2799 try { 2800 clazz=Class.forName(classname); 2801 } catch (ClassNotFoundException e) { 2802 e.printStackTrace(); 2803 } 2804 if(clazz==null)clazz=ClassUtil.loadClass(config.getClassLoader(),classname); 2805 _doVerifyDatasource(clazz, dsn, username, password); 2806 } 2807 catch (ClassException e) { 2808 throw Caster.toPageException(e); 2809 } 2810 } 2811 2812 private void _doVerifyDatasource(Class clazz, String dsn, String username, String password) throws PageException { 2813 if(!Reflector.isInstaneOf(clazz,Driver.class)) 2814 throw new DatabaseException("class ["+clazz.getName()+"] is not a JDBC Driver","class must implement interface [java.sql.Driver]",null,null,null); 2815 getConnection(dsn, username, password); 2816 } 2817 2818 private void _doVerifyDatasource(String name, String username, String password) throws PageException { 2819 DataSourceManager manager = pageContext.getDataSourceManager(); 2820 manager.releaseConnection(pageContext,manager.getConnection(pageContext,name, username, password)); 2821 //config.getConnection(name, username, password); 2822 } 2823 2824 2825 private Connection getConnection(String dsn, String user, String pass) throws DatabaseException { 2826 Connection conn=null; 2827 try { 2828 conn = DBUtil.getConnection(dsn, user, pass); 2829 conn.setAutoCommit(true); 2830 } 2831 catch (SQLException e) { 2832 throw new DatabaseException(e,null); 2833 } 2834 return conn; 2835 } 2836 2837 2838 2839 /** 2840 * @throws PageException 2841 * 2842 */ 2843 private void doUpdatePSQ() throws PageException { 2844 admin.updatePSQ(getBoolObject("admin",action,"psq")); 2845 store(); 2846 adminSync.broadcast(attributes, config); 2847 } 2848 2849 private void doReload() throws PageException { 2850 store(); 2851 } 2852 2853 /** 2854 * @throws PageException 2855 * 2856 */ 2857 private void doRemoveDatasource() throws PageException { 2858 admin.removeDataSource(getString("admin",action,"name")); 2859 store(); 2860 adminSync.broadcast(attributes, config); 2861 } 2862 2863 private void doTerminateRunningThread() throws PageException { 2864 int id = getInt("admin", "RemoveRunningThread", "id"); 2865 2866 if(type==TYPE_WEB){ 2867 terminateRunningThread(pageContext.getConfig(),id); 2868 } 2869 else { 2870 ConfigServer cs = pageContext.getConfig().getConfigServer(password); 2871 ConfigWeb[] webs = cs.getConfigWebs(); 2872 for(int i=0;i<webs.length;i++){ 2873 if(terminateRunningThread(webs[i],id))break; 2874 } 2875 } 2876 } 2877 2878 2879 2880 2881 private static boolean terminateRunningThread(ConfigWeb configWeb,int id) { 2882 2883 Struct pcs = ((CFMLFactoryImpl)configWeb.getFactory()).getRunningPageContextes(); 2884 2885 Iterator it = pcs.keyIterator(); 2886 PageContextImpl pc; 2887 Collection.Key key; 2888 while(it.hasNext()) { 2889 key=KeyImpl.toKey(it.next(),null); 2890 pc=(PageContextImpl) pcs.get(key,null); 2891 if(pc.getId()==id){ 2892 CFMLFactoryImpl.terminate(pc); 2893 return true; 2894 } 2895 } 2896 return false; 2897 } 2898 2899 private void doRemoveRemoteClient() throws PageException { 2900 admin.removeRemoteClient(getString("admin",action,"url")); 2901 store(); 2902 } 2903 private void doRemoveSpoolerTask() throws PageException { 2904 config.getSpoolerEngine().remove(getString("admin",action,"id")); 2905 } 2906 private void doRemoveAllSpoolerTask() { 2907 ((SpoolerEngineImpl)config.getSpoolerEngine()).removeAll(); 2908 } 2909 private void doExecuteSpoolerTask() throws PageException { 2910 PageException pe = config.getSpoolerEngine().execute(getString("admin",action,"id")); 2911 if(pe!=null) throw pe; 2912 } 2913 2914 /** 2915 * @throws PageException 2916 * 2917 */ 2918 private void doGetDatasourceSetting() throws PageException { 2919 Struct sct=new StructImpl(); 2920 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 2921 sct.set("psq",Caster.toBoolean(config.getPSQL())); 2922 } 2923 2924 private void doGetORMSetting() throws PageException { 2925 pageContext.setVariable(getString("admin",action,"returnVariable"),config.getORMConfig().toStruct()); 2926 } 2927 2928 private void doGetORMEngine() throws PageException { 2929 pageContext.setVariable(getString("admin",action,"returnVariable"),config.getORMEngineClass().getName()); 2930 } 2931 2932 2933 private void doUpdateORMSetting() throws SecurityException, PageException { 2934 ORMConfiguration oc = config.getORMConfig(); 2935 Struct settings=new StructImpl(); 2936 2937 settings.set(ORMConfigurationImpl.AUTO_GEN_MAP, getBool("admin",action,"autogenmap")); 2938 settings.set(ORMConfigurationImpl.EVENT_HANDLING, getBool("admin",action,"eventHandling")); 2939 settings.set(ORMConfigurationImpl.FLUSH_AT_REQUEST_END, getBool("admin",action,"flushatrequestend")); 2940 settings.set(ORMConfigurationImpl.LOG_SQL, getBool("admin",action,"logSQL")); 2941 settings.set(ORMConfigurationImpl.SAVE_MAPPING, getBool("admin",action,"savemapping")); 2942 settings.set(ORMConfigurationImpl.USE_DB_FOR_MAPPING, getBool("admin",action,"useDBForMapping")); 2943 settings.set(ORMConfigurationImpl.SECONDARY_CACHE_ENABLED, getBool("admin",action,"secondarycacheenabled")); 2944 2945 settings.set(ORMConfigurationImpl.CATALOG, getString("admin",action,"catalog")); 2946 settings.set(ORMConfigurationImpl.SCHEMA, getString("admin",action,"schema")); 2947 settings.set(ORMConfigurationImpl.SQL_SCRIPT, getString("admin",action,"sqlscript")); 2948 settings.set(ORMConfigurationImpl.CACHE_CONFIG, getString("admin",action,"cacheconfig")); 2949 settings.set(ORMConfigurationImpl.CACHE_PROVIDER, getString("admin",action,"cacheProvider")); 2950 settings.set(ORMConfigurationImpl.ORM_CONFIG, getString("admin",action,"ormConfig")); 2951 2952 2953 // dbcreate 2954 String strDbcreate=getString("admin",action,"dbcreate"); 2955 String dbcreate="none"; 2956 if("none".equals(strDbcreate)) dbcreate="none"; 2957 else if("update".equals(strDbcreate)) dbcreate="update"; 2958 else if("dropcreate".equals(strDbcreate)) dbcreate="dropcreate"; 2959 else throw new ApplicationException("invalid dbcreate definition ["+strDbcreate+"], valid dbcreate definitions are [none,update,dropcreate]"); 2960 settings.set(ORMConfigurationImpl.DB_CREATE, dbcreate); 2961 2962 // cfclocation 2963 String strCfclocation=getString("admin",action,"cfclocation"); 2964 Array arrCfclocation = railo.runtime.type.util.ListUtil.listToArray(strCfclocation, ",\n"); 2965 Iterator it = arrCfclocation.valueIterator(); 2966 String path; 2967 while(it.hasNext()){ 2968 path=(String) it.next(); 2969 ResourceUtil.toResourceExisting(config, path); 2970 } 2971 settings.set(KeyConstants._cfcLocation, arrCfclocation); 2972 2973 admin.updateORMSetting(ORMConfigurationImpl.load(config, null, settings, null, oc)); 2974 2975 2976 store(); 2977 adminSync.broadcast(attributes, config); 2978 } 2979 2980 private void doResetORMSetting() throws SecurityException, PageException { 2981 config.getORMConfig(); 2982 admin.resetORMSetting(); 2983 store(); 2984 adminSync.broadcast(attributes, config); 2985 } 2986 2987 2988 2989 private void doUpdatePerformanceSettings() throws SecurityException, PageException { 2990 admin.updateInspectTemplate(getString("admin",action,"inspectTemplate")); 2991 store(); 2992 adminSync.broadcast(attributes, config); 2993 } 2994 2995 2996 private void doUpdateCompilerSettings() throws SecurityException, PageException { 2997 admin.updateCompilerSettings( 2998 getBoolObject("admin", "UpdateCompilerSettings", "dotNotationUpperCase"), 2999 getBoolObject("admin", "UpdateCompilerSettings", "supressWSBeforeArg"), 3000 getBoolObject("admin", "UpdateCompilerSettings", "nullSupport") 3001 ); 3002 store(); 3003 adminSync.broadcast(attributes, config); 3004 } 3005 3006 private void doGetLogSetting() throws PageException { 3007 String name=getString("admin", "GetLogSetting", "name"); 3008 name=name.trim().toLowerCase(); 3009 Query qry=_doGetLogSettings(); 3010 3011 int records = qry.getRecordcount(); 3012 for(int row=1;row<=records;row++){ 3013 String n = Caster.toString(qry.getAt("name", row, null),null); 3014 if(!StringUtil.isEmpty(n) && n.trim().equalsIgnoreCase(name)) { 3015 Struct sct=new StructImpl(); 3016 String returnVariable=getString("admin",action,"returnVariable"); 3017 pageContext.setVariable(returnVariable,sct); 3018 3019 sct.setEL(KeyConstants._name, qry.getAt(KeyConstants._name, row, "")); 3020 sct.setEL(KeyConstants._level, qry.getAt(KeyConstants._level, row, "")); 3021 sct.setEL("virtualpath", qry.getAt("virtualpath", row, "")); 3022 sct.setEL(KeyConstants._class, qry.getAt(KeyConstants._class, row, "")); 3023 sct.setEL("maxFile", qry.getAt("maxFile", row, "")); 3024 sct.setEL("maxFileSize", qry.getAt("maxFileSize", row, "")); 3025 sct.setEL(KeyConstants._path, qry.getAt(KeyConstants._path, row, "")); 3026 3027 return; 3028 } 3029 } 3030 throw new ApplicationException("invalig log name ["+name+"]"); 3031 3032 } 3033 3034 private void doGetCompilerSettings() throws PageException { 3035 String returnVariable=getString("admin",action,"returnVariable"); 3036 Struct sct=new StructImpl(); 3037 pageContext.setVariable(returnVariable,sct); 3038 3039 sct.set("DotNotationUpperCase", config.getDotNotationUpperCase()?Boolean.TRUE:Boolean.FALSE); 3040 sct.set("supressWSBeforeArg", config.getSupressWSBeforeArg()?Boolean.TRUE:Boolean.FALSE); 3041 sct.set("nullSupport", config.getFullNullSupport()?Boolean.TRUE:Boolean.FALSE); 3042 } 3043 3044 private void doGetLogSettings() throws PageException { 3045 String returnVariable=getString("admin",action,"returnVariable"); 3046 pageContext.setVariable(returnVariable,_doGetLogSettings()); 3047 } 3048 3049 private Query _doGetLogSettings() throws PageException { 3050 Query qry=new QueryImpl( 3051 new String[]{"name","level","path","virtualpath","class","maxFile","maxFileSize"}, 3052 new String[]{"varchar","varchar","varchar","varchar","varchar","varchar","varchar"}, 3053 0,railo.runtime.type.util.ListUtil.last("logs", '.')); 3054 int row=0; 3055 3056 doGetLogSettings(qry,"application",config.getApplicationLogger(),++row); 3057 doGetLogSettings(qry,"scope",config.getScopeLogger(),++row); 3058 doGetLogSettings(qry,"exception",config.getExceptionLogger(),++row); 3059 if(config instanceof ConfigWeb)doGetLogSettings(qry,"gateway",((ConfigWebImpl)config).getGatewayLogger(),++row); 3060 doGetLogSettings(qry,"mail",config.getMailLogger(),++row); 3061 doGetLogSettings(qry,"mapping",config.getMappingLogger(),++row); 3062 doGetLogSettings(qry,"orm",config.getORMLogger(),++row); 3063 doGetLogSettings(qry,"remote-client",config.getRemoteClientLog(),++row); 3064 doGetLogSettings(qry,"request-timeout",config.getRequestTimeoutLogger(),++row); 3065 if(config instanceof ConfigWeb){ 3066 doGetLogSettings(qry,"schedule-task",config.getScheduleLogger(),++row); 3067 doGetLogSettings(qry,"search",config.getSearchEngine().getLogger(),++row); 3068 } 3069 doGetLogSettings(qry,"thread",config.getThreadLogger(),++row); 3070 doGetLogSettings(qry,"trace",config.getTraceLogger(),++row); 3071 return qry; 3072 } 3073 3074 3075 private void doGetLogSettings(Query qry, String name,LogAndSource log, int row) { 3076 qry.addRow(); 3077 qry.setAtEL("name", row, name); 3078 qry.setAtEL("level", row, LogUtil.toStringType(log.getLogLevel(), "")); 3079 qry.setAtEL("virtualpath", row, log.getSource()); 3080 qry.setAtEL("class", row, log.getLog().getClass().getName()); 3081 Log l = log.getLog(); 3082 if(l instanceof LogResource){ 3083 LogResource lr = (LogResource)l; 3084 qry.setAtEL("maxFile", row, Caster.toString(lr.getMaxFiles())); 3085 qry.setAtEL("maxFileSize", row, Caster.toString(lr.getMaxFileSize())); 3086 qry.setAtEL("path", row, lr.getResource().getAbsolutePath()); 3087 } 3088 3089 3090 } 3091 3092 private void doGetPerformanceSettings() throws ApplicationException, PageException { 3093 Struct sct=new StructImpl(); 3094 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 3095 3096 short it = config.getInspectTemplate(); 3097 String str="once"; 3098 if(it==ConfigImpl.INSPECT_ALWAYS)str="always"; 3099 else if(it==ConfigImpl.INSPECT_NEVER)str="never"; 3100 sct.set("inspectTemplate",str); 3101 } 3102 3103 3104 private void doGetCustomTagSetting() throws PageException { 3105 Struct sct=new StructImpl(); 3106 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 3107 sct.set("customTagDeepSearch",Caster.toBoolean(config.doCustomTagDeepSearch()));// deprecated 3108 sct.set("customTagLocalSearch",Caster.toBoolean(config.doLocalCustomTag()));// deprecated 3109 3110 sct.set("deepSearch",Caster.toBoolean(config.doCustomTagDeepSearch())); 3111 sct.set("localSearch",Caster.toBoolean(config.doLocalCustomTag())); 3112 sct.set("customTagPathCache",Caster.toBoolean(config.useCTPathCache())); 3113 sct.set("extensions",new ArrayImpl(config.getCustomTagExtensions())); 3114 } 3115 3116 private void doGetDatasourceDriverList() throws PageException { 3117 Resource railoContext = ResourceUtil.toResourceExisting(pageContext ,"/railo-context/admin/dbdriver/"); 3118 Resource[] children = railoContext.listResources(new ExtensionResourceFilter("cfc")); 3119 String rtnVar=getString("admin",action,"returnVariable"); 3120 3121 railo.runtime.type.Query qry=new QueryImpl(new String[]{"name"},children.length,rtnVar); 3122 3123 3124 for(int i=0;i<children.length;i++) { 3125 qry.setAt("name", i+1, children[i].getName()); 3126 } 3127 pageContext.setVariable(rtnVar,qry); 3128 3129 } 3130 3131 /*private String getContextPath() { 3132 String cp = pageContext. getHttpServletRequest().getContextPath(); 3133 if(cp==null)return ""; 3134 return cp; 3135 }*/ 3136 3137 private void doGetDebuggingList() throws PageException { 3138 Resource railoContext = ResourceUtil.toResourceExisting(pageContext ,"/railo-context/templates/debugging/"); 3139 Resource[] children = railoContext.listResources(new ExtensionResourceFilter("cfm")); 3140 String rtnVar=getString("admin",action,"returnVariable"); 3141 3142 railo.runtime.type.Query qry=new QueryImpl(new String[]{"name"},children.length,rtnVar); 3143 3144 3145 for(int i=0;i<children.length;i++) { 3146 qry.setAt("name", i+1, children[i].getName()); 3147 } 3148 pageContext.setVariable(rtnVar,qry); 3149 3150 } 3151 3152 private void doGetGatewayEntries() throws PageException { 3153 Map entries = ((ConfigWebImpl)config).getGatewayEngine().getEntries(); 3154 Iterator it = entries.entrySet().iterator(); 3155 railo.runtime.type.Query qry= 3156 new QueryImpl(new String[]{"class","id","custom","cfcPath","listenerCfcPath","startupMode","state","readOnly"}, 0, "entries"); 3157 Map.Entry entry; 3158 GatewayEntry ge; 3159 //Gateway g; 3160 int row=0; 3161 while(it.hasNext()){ 3162 row++; 3163 entry=(Entry) it.next(); 3164 ge=(GatewayEntry) entry.getValue(); 3165 //g=ge.getGateway(); 3166 qry.addRow(); 3167 qry.setAtEL("class", row, ge.getClassName()); 3168 qry.setAtEL("id", row, ge.getId()); 3169 qry.setAtEL("listenerCfcPath", row, ge.getListenerCfcPath()); 3170 qry.setAtEL("cfcPath", row, ge.getCfcPath()); 3171 qry.setAtEL("startupMode", row, GatewayEntryImpl.toStartup(ge.getStartupMode(),"automatic")); 3172 qry.setAtEL("custom", row, ge.getCustom()); 3173 qry.setAtEL("readOnly", row, Caster.toBoolean(ge.isReadOnly())); 3174 qry.setAtEL("state",row,GatewayEngineImpl.toStringState(GatewayUtil.getState(ge), "failed")); 3175 3176 } 3177 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 3178 } 3179 3180 3181 private void doGetMonitors() throws PageException { 3182 if(!(config instanceof ConfigServerImpl)) 3183 throw new ApplicationException("invalid context for this action"); 3184 3185 ConfigServerImpl cs=(ConfigServerImpl) config; 3186 IntervallMonitor[] intervalls = cs.getIntervallMonitors(); 3187 RequestMonitor[] requests = cs.getRequestMonitors(); 3188 3189 railo.runtime.type.Query qry= 3190 new QueryImpl(new Collection.Key[]{KeyConstants._name,KeyConstants._type,LOG_ENABLED,CLASS}, 0, "monitors"); 3191 doGetMonitors(qry,intervalls); 3192 doGetMonitors(qry,requests); 3193 3194 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 3195 } 3196 private void doGetMonitor() throws PageException { 3197 if(!(config instanceof ConfigServerImpl)) 3198 throw new ApplicationException("invalid context for this action"); 3199 ConfigServerImpl cs=(ConfigServerImpl) config; 3200 3201 String type=getString("admin",action,"monitorType"); 3202 String name=getString("admin",action,"name"); 3203 type=type.trim(); 3204 Monitor m; 3205 if("request".equalsIgnoreCase(type)) 3206 m=cs.getRequestMonitor(name); 3207 else 3208 m=cs.getIntervallMonitor(name); 3209 3210 Struct sct=new StructImpl(); 3211 sct.setEL(KeyConstants._name, m.getName()); 3212 sct.setEL(KeyConstants._type, m.getType()==Monitor.TYPE_INTERVALL?"intervall":"request"); 3213 sct.setEL(LOG_ENABLED, m.isLogEnabled()); 3214 sct.setEL(CLASS, m.getClazz().getName()); 3215 3216 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 3217 } 3218 3219 3220 3221 private void doGetExecutionLog() throws PageException { 3222 ExecutionLogFactory factory = config.getExecutionLogFactory(); 3223 Struct sct=new StructImpl(); 3224 3225 sct.set(KeyConstants._enabled, Caster.toBoolean(config.getExecutionLogEnabled())); 3226 Class clazz = factory.getClazz(); 3227 sct.set(KeyConstants._class, clazz!=null?clazz.getName():""); 3228 sct.set(KeyConstants._arguments, factory.getArgumentsAsStruct()); 3229 3230 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 3231 } 3232 3233 3234 3235 3236 private void doGetMonitors(Query qry, Monitor[] monitors) { 3237 Monitor m; 3238 int row; 3239 for(int i=0;i<monitors.length;i++){ 3240 m=monitors[i]; 3241 row=qry.addRow(); 3242 qry.setAtEL(KeyConstants._name, row, m.getName()); 3243 qry.setAtEL(KeyConstants._type, row, m.getType()==Monitor.TYPE_INTERVALL?"intervall":"request"); 3244 qry.setAtEL(LOG_ENABLED, row, m.isLogEnabled()); 3245 qry.setAtEL(CLASS, row, m.getClazz().getName()); 3246 } 3247 3248 } 3249 3250 private void doGetGatewayEntry() throws PageException { 3251 3252 String id=getString("admin",action,"id"); 3253 Map entries = ((ConfigWebImpl)config).getGatewayEngine().getEntries(); 3254 Iterator it = entries.keySet().iterator(); 3255 GatewayEntry ge; 3256 //Gateway g; 3257 Struct sct; 3258 while(it.hasNext()) { 3259 String key=(String)it.next(); 3260 if(key.equalsIgnoreCase(id)) { 3261 ge=(GatewayEntry) entries.get(key); 3262 //g=ge.getGateway(); 3263 sct=new StructImpl(); 3264 sct.setEL("id",ge.getId()); 3265 sct.setEL("class",ge.getClassName()); 3266 sct.setEL("listenerCfcPath", ge.getListenerCfcPath()); 3267 sct.setEL("cfcPath",ge.getCfcPath()); 3268 sct.setEL("startupMode",GatewayEntryImpl.toStartup(ge.getStartupMode(),"automatic")); 3269 sct.setEL("custom",ge.getCustom()); 3270 sct.setEL("readOnly",Caster.toBoolean(ge.isReadOnly())); 3271 sct.setEL("state",GatewayEngineImpl.toStringState(GatewayUtil.getState(ge), "failed")); 3272 3273 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 3274 return; 3275 } 3276 } 3277 throw new ApplicationException("there is no gateway entry with id ["+id+"]"); 3278 } 3279 3280 private void doGateway() throws PageException { 3281 3282 String id=getString("admin",action,"id"); 3283 String act=getString("admin",action,"gatewayAction").trim().toLowerCase(); 3284 if("restart".equals(act)) ((ConfigWebImpl)config).getGatewayEngine().restart(id); 3285 else if("start".equals(act))((ConfigWebImpl)config).getGatewayEngine().start(id); 3286 else if("stop".equals(act)) ((ConfigWebImpl)config).getGatewayEngine().stop(id); 3287 else throw new ApplicationException("invalid gateway action ["+act+"], valid actions are [start,stop,restart]"); 3288 } 3289 3290 3291 3292 private void doGetCacheConnections() throws PageException { 3293 Map conns = config.getCacheConnections(); 3294 Iterator it = conns.entrySet().iterator(); 3295 railo.runtime.type.Query qry=new QueryImpl(new String[]{"class","name","custom","default","readOnly","storage"}, 0, "connections"); 3296 Map.Entry entry; 3297 CacheConnection cc; 3298 CacheConnection defObj=config.getCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_OBJECT); 3299 CacheConnection defTmp=config.getCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_TEMPLATE); 3300 CacheConnection defQry=config.getCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_QUERY); 3301 CacheConnection defRes=config.getCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_RESOURCE); 3302 CacheConnection defUDF=config.getCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_FUNCTION); 3303 int row=0; 3304 String def; 3305 while(it.hasNext()){ 3306 row++; 3307 entry=(Entry) it.next(); 3308 cc=(CacheConnection) entry.getValue(); 3309 qry.addRow(); 3310 def=""; 3311 if(cc==defObj)def="object"; 3312 if(cc==defTmp)def="template"; 3313 if(cc==defQry)def="query"; 3314 if(cc==defRes)def="resource"; 3315 if(cc==defUDF)def="function"; 3316 qry.setAtEL("class", row, cc.getClazz().getName()); 3317 qry.setAtEL("name", row, cc.getName()); 3318 qry.setAtEL("custom", row, cc.getCustom()); 3319 qry.setAtEL("default", row, def); 3320 qry.setAtEL("readOnly", row, Caster.toBoolean(cc.isReadOnly())); 3321 qry.setAtEL("storage", row, Caster.toBoolean(cc.isStorage())); 3322 3323 } 3324 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 3325 } 3326 3327 3328 private void doGetCacheDefaultConnection() throws PageException { 3329 int type; 3330 String strType=getString("admin", "GetCacheDefaultConnection", "cacheType"); 3331 strType=strType.toLowerCase().trim(); 3332 if(strType.equals("object")) 3333 type=ConfigImpl.CACHE_DEFAULT_OBJECT; 3334 else if(strType.equals("template")) 3335 type=ConfigImpl.CACHE_DEFAULT_TEMPLATE; 3336 else if(strType.equals("query")) 3337 type=ConfigImpl.CACHE_DEFAULT_QUERY; 3338 else if(strType.equals("resource")) 3339 type=ConfigImpl.CACHE_DEFAULT_RESOURCE; 3340 else if(strType.equals("function")) 3341 type=ConfigImpl.CACHE_DEFAULT_FUNCTION; 3342 else 3343 throw new ApplicationException("inv,query,resourcealid type defintion, valid values are [object, template,query,resource,function]"); 3344 3345 CacheConnection cc = config.getCacheDefaultConnection(type); 3346 if(cc!=null){ 3347 Struct sct=new StructImpl(); 3348 3349 sct.setEL(KeyConstants._name,cc.getName()); 3350 sct.setEL("class",cc.getClazz().getName()); 3351 sct.setEL("custom",cc.getCustom()); 3352 sct.setEL("default",Caster.toBoolean(true)); 3353 sct.setEL("readOnly",Caster.toBoolean(cc.isReadOnly())); 3354 3355 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 3356 } 3357 else throw new ApplicationException("there is no cache default connection"); 3358 } 3359 3360 private void doGetCacheConnection() throws PageException { 3361 3362 String name=getString("admin",action,"name"); 3363 Map conns = config.getCacheConnections(); 3364 Iterator it = conns.keySet().iterator(); 3365 CacheConnection cc; 3366 CacheConnection dObj=config.getCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_OBJECT); 3367 CacheConnection dTmp=config.getCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_TEMPLATE); 3368 CacheConnection dQry=config.getCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_QUERY); 3369 CacheConnection dRes=config.getCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_RESOURCE); 3370 CacheConnection dUDF=config.getCacheDefaultConnection(ConfigImpl.CACHE_DEFAULT_FUNCTION); 3371 3372 Struct sct; 3373 String d; 3374 while(it.hasNext()) { 3375 String key=(String)it.next(); 3376 if(key.equalsIgnoreCase(name)) { 3377 cc=(CacheConnection) conns.get(key); 3378 sct=new StructImpl(); 3379 d=""; 3380 if(cc==dObj)d="object"; 3381 else if(cc==dTmp)d="template"; 3382 else if(cc==dQry)d="query"; 3383 else if(cc==dRes)d="resource"; 3384 else if(cc==dUDF)d="function"; 3385 sct.setEL(KeyConstants._name,cc.getName()); 3386 sct.setEL(KeyConstants._class,cc.getClazz().getName()); 3387 sct.setEL(KeyConstants._custom,cc.getCustom()); 3388 sct.setEL(KeyConstants._default,d); 3389 sct.setEL("readOnly",Caster.toBoolean(cc.isReadOnly())); 3390 sct.setEL("storage",Caster.toBoolean(cc.isStorage())); 3391 3392 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 3393 return; 3394 } 3395 } 3396 throw new ApplicationException("there is no cache connection with name ["+name+"]"); 3397 } 3398 3399 private void doRemoveCacheConnection() throws PageException { 3400 admin.removeCacheConnection(getString("admin",action,"name")); 3401 store(); 3402 adminSync.broadcast(attributes, config); 3403 } 3404 3405 private void doRemoveGatewayEntry() throws PageException { 3406 admin.removeCacheGatewayEntry(getString("admin",action,"id")); 3407 store(); 3408 adminSync.broadcast(attributes, config); 3409 } 3410 3411 private void doRemoveDebugEntry() throws PageException { 3412 admin.removeDebugEntry(getString("admin",action,"id")); 3413 store(); 3414 adminSync.broadcast(attributes, config); 3415 } 3416 3417 private void doVerifyCacheConnection() throws PageException { 3418 3419 3420 try { 3421 Cache cache = Util.getCache(pageContext.getConfig(), getString("admin",action,"name")); 3422 if(cache instanceof Cache2) 3423 ((Cache2)cache).verify(); 3424 else 3425 cache.getCustomInfo(); 3426 } catch (IOException e) { 3427 throw Caster.toPageException(e); 3428 } 3429 } 3430 3431 /** 3432 * @throws PageException 3433 * 3434 */ 3435 private void doGetDatasource() throws PageException { 3436 3437 String name=getString("admin",action,"name"); 3438 Map ds = config.getDataSourcesAsMap(); 3439 Iterator it = ds.keySet().iterator(); 3440 3441 while(it.hasNext()) { 3442 String key=(String)it.next(); 3443 if(key.equalsIgnoreCase(name)) { 3444 DataSource d=(DataSource) ds.get(key); 3445 Struct sct=new StructImpl(); 3446 3447 sct.setEL(KeyConstants._name,key); 3448 sct.setEL(KeyConstants._host,d.getHost()); 3449 sct.setEL("classname",d.getClazz().getName()); 3450 sct.setEL("dsn",d.getDsnOriginal()); 3451 sct.setEL("database",d.getDatabase()); 3452 sct.setEL("port",d.getPort()<1?"":Caster.toString(d.getPort())); 3453 sct.setEL("dsnTranslated",d.getDsnTranslated()); 3454 sct.setEL("timezone",toStringTimeZone(d.getTimeZone())); 3455 sct.setEL("password",d.getPassword()); 3456 sct.setEL("passwordEncrypted",ConfigWebFactory.encrypt(d.getPassword())); 3457 sct.setEL("username",d.getUsername()); 3458 sct.setEL("readonly",Caster.toBoolean(d.isReadOnly())); 3459 sct.setEL("select",Boolean.valueOf(d.hasAllow(DataSource.ALLOW_SELECT))); 3460 sct.setEL("delete",Boolean.valueOf(d.hasAllow(DataSource.ALLOW_DELETE))); 3461 sct.setEL("update",Boolean.valueOf(d.hasAllow(DataSource.ALLOW_UPDATE))); 3462 sct.setEL("insert",Boolean.valueOf(d.hasAllow(DataSource.ALLOW_INSERT))); 3463 sct.setEL("create",Boolean.valueOf(d.hasAllow(DataSource.ALLOW_CREATE))); 3464 sct.setEL("insert",Boolean.valueOf(d.hasAllow(DataSource.ALLOW_INSERT))); 3465 sct.setEL("drop",Boolean.valueOf(d.hasAllow(DataSource.ALLOW_DROP))); 3466 sct.setEL("grant",Boolean.valueOf(d.hasAllow(DataSource.ALLOW_GRANT))); 3467 sct.setEL("revoke",Boolean.valueOf(d.hasAllow(DataSource.ALLOW_REVOKE))); 3468 sct.setEL("alter",Boolean.valueOf(d.hasAllow(DataSource.ALLOW_ALTER))); 3469 3470 sct.setEL("connectionLimit",d.getConnectionLimit()<1?"":Caster.toString(d.getConnectionLimit())); 3471 sct.setEL("connectionTimeout",d.getConnectionTimeout()<1?"":Caster.toString(d.getConnectionTimeout())); 3472 sct.setEL("metaCacheTimeout",Caster.toDouble(d.getMetaCacheTimeout())); 3473 sct.setEL("custom",d.getCustoms()); 3474 sct.setEL("blob",Boolean.valueOf(d.isBlob())); 3475 sct.setEL("clob",Boolean.valueOf(d.isClob())); 3476 sct.setEL("validate",Boolean.valueOf(d.validate())); 3477 sct.setEL("storage",Boolean.valueOf(d.isStorage())); 3478 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 3479 return; 3480 } 3481 } 3482 throw new ApplicationException("there is no datasource with name ["+name+"]"); 3483 } 3484 private Object toStringTimeZone(TimeZone timeZone) { 3485 if(timeZone==null) return ""; 3486 return timeZone.getID(); 3487 } 3488 3489 private void doGetRemoteClient() throws PageException { 3490 3491 String url=getString("admin",action,"url"); 3492 RemoteClient[] clients = config.getRemoteClients(); 3493 RemoteClient client; 3494 for(int i=0;i<clients.length;i++) { 3495 client=clients[i]; 3496 3497 if(client.getUrl().equalsIgnoreCase(url)) { 3498 Struct sct=new StructImpl(); 3499 ProxyData pd = client.getProxyData(); 3500 sct.setEL("label",client.getLabel()); 3501 sct.setEL("usage",client.getUsage()); 3502 sct.setEL("securityKey",client.getSecurityKey()); 3503 sct.setEL("adminPassword",client.getAdminPassword()); 3504 sct.setEL("ServerUsername",client.getServerUsername()); 3505 sct.setEL("ServerPassword",client.getServerPassword()); 3506 sct.setEL("type",client.getType()); 3507 sct.setEL("url",client.getUrl()); 3508 sct.setEL("proxyServer",pd==null?"":StringUtil.emptyIfNull(pd.getServer())); 3509 sct.setEL("proxyUsername",pd==null?"":StringUtil.emptyIfNull(pd.getUsername())); 3510 sct.setEL("proxyPassword",pd==null?"":StringUtil.emptyIfNull(pd.getPassword())); 3511 sct.setEL("proxyPort",pd==null?"":(pd.getPort()==-1?"":Caster.toString(pd.getPort()))); 3512 3513 3514 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 3515 return; 3516 } 3517 } 3518 throw new ApplicationException("there is no remote client with url ["+url+"]"); 3519 } 3520 3521 private void doGetSpoolerTasks() throws PageException { 3522 int startrow = getInt("startrow",1); 3523 if(startrow <1) startrow=1; 3524 int maxrow = getInt("maxrow",-1); 3525 String result=getString("result", null); 3526 SpoolerEngineImpl engine = (SpoolerEngineImpl) config.getSpoolerEngine(); 3527 3528 Query qry = engine.getAllTasksAsQuery(startrow,maxrow); 3529 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 3530 if(!StringUtil.isEmpty(result)){ 3531 Struct sct=new StructImpl(); 3532 pageContext.setVariable(result,sct); 3533 sct.setEL("open", engine.getOpenTaskCount()); 3534 sct.setEL("closed", engine.getClosedTaskCount()); 3535 } 3536 3537 /* 3538 SpoolerTask[] open = config.getSpoolerEngine().getOpenTasks(); 3539 SpoolerTask[] closed = config.getSpoolerEngine().getClosedTasks(); 3540 String v="VARCHAR"; 3541 railo.runtime.type.Query qry=new QueryImpl( 3542 new String[]{"type","name","detail","id","lastExecution","nextExecution","closed","tries","exceptions","triesmax"}, 3543 new String[]{v,v,"object",v,d,d,"boolean","int","object","int"}, 3544 open.length+closed.length,"query"); 3545 3546 int row=0; 3547 row=doGetRemoteClientTasks(qry,open,row); 3548 doGetRemoteClientTasks(qry,closed,row); 3549 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 3550 */ 3551 3552 3553 3554 } 3555 3556 private int doGetRemoteClientTasks(railo.runtime.type.Query qry, SpoolerTask[] tasks, int row) { 3557 SpoolerTask task; 3558 for(int i=0;i<tasks.length;i++) { 3559 row++; 3560 task=tasks[i]; 3561 try{ 3562 qry.setAt("type", row, task.getType()); 3563 qry.setAt("name", row, task.subject()); 3564 qry.setAt("detail", row, task.detail()); 3565 qry.setAt("id", row, task.getId()); 3566 3567 3568 qry.setAt("lastExecution", row,new DateTimeImpl(pageContext,task.lastExecution(),true)); 3569 qry.setAt("nextExecution", row,new DateTimeImpl(pageContext,task.nextExecution(),true)); 3570 qry.setAt("closed", row,Caster.toBoolean(task.closed())); 3571 qry.setAt("tries", row,Caster.toDouble(task.tries())); 3572 qry.setAt("triesmax", row,Caster.toDouble(task.tries())); 3573 qry.setAt("exceptions", row,translateTime(task.getExceptions())); 3574 3575 int triesMax=0; 3576 ExecutionPlan[] plans = task.getPlans(); 3577 for(int y=0;y<plans.length;y++) { 3578 triesMax+=plans[y].getTries(); 3579 } 3580 qry.setAt("triesmax", row,Caster.toDouble(triesMax)); 3581 } 3582 catch(Throwable t){} 3583 } 3584 return row; 3585 } 3586 3587 private Array translateTime(Array exp) { 3588 exp=(Array) Duplicator.duplicate(exp,true); 3589 Iterator<Object> it = exp.valueIterator(); 3590 Struct sct; 3591 while(it.hasNext()) { 3592 sct=(Struct) it.next(); 3593 sct.setEL("time",new DateTimeImpl(pageContext,Caster.toLongValue(sct.get("time",null),0),true)); 3594 } 3595 return exp; 3596 } 3597 3598 private void doGetRemoteClients() throws PageException { 3599 RemoteClient[] clients = config.getRemoteClients(); 3600 RemoteClient client; 3601 ProxyData pd; 3602 railo.runtime.type.Query qry=new QueryImpl(new String[]{"label","usage","securityKey","adminPassword","serverUsername","serverPassword","type","url", 3603 "proxyServer","proxyUsername","proxyPassword","proxyPort"},clients.length,"query"); 3604 3605 int row=0; 3606 3607 for(int i=0;i<clients.length;i++) { 3608 client=clients[i]; 3609 pd=client.getProxyData(); 3610 row=i+1; 3611 qry.setAt("label",row,client.getLabel()); 3612 qry.setAt("usage",row,client.getUsage()); 3613 qry.setAt("securityKey",row,client.getSecurityKey()); 3614 qry.setAt("adminPassword",row,client.getAdminPassword()); 3615 qry.setAt("ServerUsername",row,client.getServerUsername()); 3616 qry.setAt("ServerPassword",row,client.getServerPassword()); 3617 qry.setAt("type",row,client.getType()); 3618 qry.setAt("url",row,client.getUrl()); 3619 qry.setAt("proxyServer",row,pd==null?"":pd.getServer()); 3620 qry.setAt("proxyUsername",row,pd==null?"":pd.getUsername()); 3621 qry.setAt("proxyPassword",row,pd==null?"":pd.getPassword()); 3622 qry.setAt("proxyPort",row,pd==null?"":Caster.toString(pd.getPort())); 3623 3624 } 3625 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 3626 } 3627 3628 private void doSetCluster() {// MUST remove this 3629 try { 3630 _doSetCluster(); 3631 } catch (Throwable t) { 3632 //print.printST(t); 3633 } 3634 } 3635 3636 private void _doSetCluster() throws PageException { 3637 3638 Struct entries = Caster.toStruct(getObject("admin",action,"entries")); 3639 Struct entry; 3640 Iterator<Object> it = entries.valueIterator(); 3641 Cluster cluster = pageContext.clusterScope(); 3642 while(it.hasNext()) { 3643 entry=Caster.toStruct(it.next()); 3644 cluster.setEntry( 3645 new ClusterEntryImpl( 3646 KeyImpl.getInstance(Caster.toString(entry.get(KeyConstants._key))), 3647 Caster.toSerializable(entry.get(KeyConstants._value,null),null), 3648 Caster.toLongValue(entry.get(KeyConstants._time)) 3649 ) 3650 ); 3651 } 3652 3653 cluster.broadcast(); 3654 } 3655 3656 3657 private void doGetCluster() throws PageException { 3658 pageContext.setVariable( 3659 getString("admin",action,"returnVariable"), 3660 ((PageContextImpl)pageContext).clusterScope(false) 3661 ); 3662 } 3663 3664 private void doGetToken() throws PageException { 3665 pageContext.setVariable( 3666 getString("admin",action,"returnVariable"), 3667 config.getSecurityToken() 3668 ); 3669 } 3670 3671 3672 3673 3674 /** 3675 * @throws PageException 3676 * 3677 */ 3678 private void doGetDatasources() throws PageException { 3679 3680 3681 Map ds = config.getDataSourcesAsMap(); 3682 Iterator it = ds.keySet().iterator(); 3683 railo.runtime.type.Query qry=new QueryImpl(new String[]{"name","host","classname","dsn","DsnTranslated","database","port", 3684 "timezone","username","password","readonly" 3685 ,"grant","drop","create","revoke","alter","select","delete","update","insert" 3686 ,"connectionLimit","connectionTimeout","clob","blob","validate","storage","customSettings"},ds.size(),"query"); 3687 3688 int row=0; 3689 3690 while(it.hasNext()) { 3691 Object key=it.next(); 3692 DataSource d=(DataSource) ds.get(key); 3693 row++; 3694 qry.setAt(KeyConstants._name,row,key); 3695 qry.setAt(KeyConstants._host,row,d.getHost()); 3696 qry.setAt("classname",row,d.getClazz().getName()); 3697 //qry.setAt("driverversion",row,getDriverVersion(d.getClazz())); 3698 qry.setAt("dsn",row,d.getDsnOriginal()); 3699 qry.setAt("database",row,d.getDatabase()); 3700 qry.setAt(KeyConstants._port,row,d.getPort()<1?"":Caster.toString(d.getPort())); 3701 qry.setAt("dsnTranslated",row,d.getDsnTranslated()); 3702 qry.setAt("timezone",row,toStringTimeZone(d.getTimeZone())); 3703 qry.setAt(KeyConstants._password,row,d.getPassword()); 3704 qry.setAt(KeyConstants._username,row,d.getUsername()); 3705 qry.setAt(KeyConstants._readonly,row,Caster.toBoolean(d.isReadOnly())); 3706 qry.setAt(KeyConstants._select,row,Boolean.valueOf(d.hasAllow(DataSource.ALLOW_SELECT))); 3707 qry.setAt(KeyConstants._delete,row,Boolean.valueOf(d.hasAllow(DataSource.ALLOW_DELETE))); 3708 qry.setAt(KeyConstants._update,row,Boolean.valueOf(d.hasAllow(DataSource.ALLOW_UPDATE))); 3709 qry.setAt(KeyConstants._create,row,Boolean.valueOf(d.hasAllow(DataSource.ALLOW_CREATE))); 3710 qry.setAt(KeyConstants._insert,row,Boolean.valueOf(d.hasAllow(DataSource.ALLOW_INSERT))); 3711 qry.setAt(KeyConstants._drop,row,Boolean.valueOf(d.hasAllow(DataSource.ALLOW_DROP))); 3712 qry.setAt(KeyConstants._grant,row,Boolean.valueOf(d.hasAllow(DataSource.ALLOW_GRANT))); 3713 qry.setAt(KeyConstants._revoke,row,Boolean.valueOf(d.hasAllow(DataSource.ALLOW_REVOKE))); 3714 qry.setAt(KeyConstants._alter,row,Boolean.valueOf(d.hasAllow(DataSource.ALLOW_ALTER))); 3715 3716 qry.setAt("connectionLimit",row,d.getConnectionLimit()<1?"":Caster.toString(d.getConnectionLimit())); 3717 qry.setAt("connectionTimeout",row,d.getConnectionTimeout()<1?"":Caster.toString(d.getConnectionTimeout())); 3718 qry.setAt("customSettings",row,d.getCustoms()); 3719 qry.setAt("blob",row,Boolean.valueOf(d.isBlob())); 3720 qry.setAt("clob",row,Boolean.valueOf(d.isClob())); 3721 qry.setAt("validate",row,Boolean.valueOf(d.validate())); 3722 qry.setAt("storage",row,Boolean.valueOf(d.isStorage())); 3723 3724 } 3725 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 3726 } 3727 3728 3729 /** 3730 * @throws PageException 3731 * 3732 */ 3733 private void doUpdateScope() throws PageException { 3734 3735 admin.updateScopeCascadingType(getString("admin",action,"scopeCascadingType")); 3736 admin.updateAllowImplicidQueryCall(getBoolObject("admin",action,"allowImplicidQueryCall")); 3737 admin.updateMergeFormAndUrl(getBoolObject("admin",action,"mergeFormAndUrl")); 3738 admin.updateSessionManagement(getBoolObject("admin",action,"sessionManagement")); 3739 admin.updateClientManagement(getBoolObject("admin",action,"clientManagement")); 3740 admin.updateDomaincookies(getBoolObject("admin",action,"domainCookies")); 3741 admin.updateClientCookies(getBoolObject("admin",action,"clientCookies")); 3742 //admin.updateRequestTimeout(getTimespan("admin",action,"requestTimeout")); 3743 admin.updateClientTimeout(getTimespan("admin",action,"clientTimeout")); 3744 admin.updateSessionTimeout(getTimespan("admin",action,"sessionTimeout")); 3745 admin.updateApplicationTimeout(getTimespan("admin",action,"applicationTimeout")); 3746 admin.updateSessionType(getString("admin",action,"sessionType")); 3747 admin.updateLocalMode(getString("admin",action,"localMode")); 3748 store(); 3749 adminSync.broadcast(attributes, config); 3750 } 3751 3752 3753 private void doUpdateRestSettings() throws PageException { 3754 3755 admin.updateRestList(getBool("list", null)); 3756 //admin.updateRestAllowChanges(getBool("allowChanges", null)); 3757 store(); 3758 adminSync.broadcast(attributes, config); 3759 } 3760 3761 private void doUpdateApplicationSettings() throws PageException { 3762 admin.updateRequestTimeout(getTimespan("admin",action,"requestTimeout")); 3763 admin.updateScriptProtect(getString("admin",action,"scriptProtect")); 3764 admin.updateAllowURLRequestTimeout(getBoolObject("admin",action,"allowURLRequestTimeout")); // DIFF 23 3765 store(); 3766 adminSync.broadcast(attributes, config); 3767 } 3768 3769 private void doUpdateOutputSettings() throws PageException { 3770 admin.updateCFMLWriterType(getString("admin",action, "cfmlWriter")); 3771 admin.updateSuppressContent(getBoolObject("admin",action, "suppressContent")); 3772 //admin.updateShowVersion(getBoolObject("admin",action, "showVersion")); 3773 admin.updateAllowCompression(getBoolObject("admin",action, "allowCompression")); 3774 admin.updateContentLength(getBoolObject("admin",action, "contentLength")); 3775 admin.updateBufferOutput(getBoolObject("admin",action, "bufferOutput")); 3776 store(); 3777 adminSync.broadcast(attributes, config); 3778 } 3779 3780 private void doUpdateCustomTagSetting() throws PageException { 3781 admin.updateCustomTagDeepSearch(getBool("admin", action, "deepSearch")); 3782 admin.updateCustomTagLocalSearch(getBool("admin", action, "localSearch")); 3783 admin.updateCTPathCache(getBool("admin", action, "customTagPathCache")); 3784 admin.updateCustomTagExtensions(getString("admin", action, "extensions")); 3785 store(); 3786 adminSync.broadcast(attributes, config); 3787 } 3788 3789 private void doUpdateUpdateLogSettings() throws PageException { 3790 int level=LogUtil.toIntType(getString("admin", "updateUpdateLogSettings", "level"), -1); 3791 String source=getString("admin", "updateUpdateLogSettings", "path"); 3792 if(source.indexOf("{")==-1){ 3793 Resource res = ResourceUtil.toResourceNotExisting(pageContext, source, false); 3794 String tmp=SystemUtil.addPlaceHolder(res, config, null); 3795 3796 3797 if(tmp!=null) source=tmp; 3798 else source=ContractPath.call(pageContext, source); 3799 } 3800 3801 admin.updateLogSettings( 3802 getString("admin", "updateUpdateLogSettings", "name"), 3803 level, 3804 source, 3805 getInt("admin", "updateUpdateLogSettings", "maxfile"), 3806 getInt("admin", "updateUpdateLogSettings", "maxfilesize") 3807 ); 3808 store(); 3809 adminSync.broadcast(attributes, config); 3810 } 3811 3812 3813 3814 private void doUpdateMonitor() throws PageException { 3815 admin.updateMonitor( 3816 getString("admin", "updateMonitor", "class"), 3817 getString("admin", "updateMonitor", "monitorType"), 3818 getString("admin", "updateMonitor", "name"), 3819 getBool("admin", "updateMonitor", "logEnabled") 3820 ); 3821 store(); 3822 adminSync.broadcast(attributes, config); 3823 } 3824 3825 private void doUpdateExecutionLog() throws PageException { 3826 admin.updateExecutionLog( 3827 getString("admin", "updateExecutionLog", "class"), 3828 getStruct("admin", "updateExecutionLog", "arguments"), 3829 getBool("admin", "updateExecutionLog", "enabled") 3830 ); 3831 store(); 3832 adminSync.broadcast(attributes, config); 3833 } 3834 3835 3836 private void doRemoveMonitor() throws PageException { 3837 admin.removeMonitor( 3838 getString("admin", "updateMonitor", "name") 3839 ); 3840 store(); 3841 adminSync.broadcast(attributes, config); 3842 } 3843 3844 private void doUpdateRHExtension() throws PageException { 3845 String str = getString("admin", "UpdateExtensions", "source"); 3846 Resource src = ResourceUtil.toResourceExisting(config, str); 3847 Resource trg=DeployHandler.getDeployDirectory(config).getRealResource(src.getName()); 3848 3849 try { 3850 ResourceUtil.copy(src, trg); 3851 } 3852 catch (IOException e) { 3853 throw Caster.toPageException(e); 3854 } 3855 //config.get 3856 DeployHandler.deploy(config); 3857 } 3858 3859 private void doUpdateExtension() throws PageException { 3860 3861 3862 admin.updateExtension(new ExtensionImpl( 3863 getStruct("config", null), 3864 getString("admin", "UpdateExtensions", "id"), 3865 getString("admin", "UpdateExtensions","provider"), 3866 getString("admin", "UpdateExtensions","version"), 3867 3868 getString("admin", "UpdateExtensions","name"), 3869 getString("admin", "UpdateExtensions","label"), 3870 getString("admin", "UpdateExtensions","description"), 3871 getString("admin", "UpdateExtensions","category"), 3872 getString("admin", "UpdateExtensions","image"), 3873 getString("admin", "UpdateExtensions","author"), 3874 getString("admin", "UpdateExtensions","codename"), 3875 getString("admin", "UpdateExtensions","video"), 3876 getString("admin", "UpdateExtensions","support"), 3877 getString("admin", "UpdateExtensions","documentation"), 3878 getString("admin", "UpdateExtensions","forum"), 3879 getString("admin", "UpdateExtensions","mailinglist"), 3880 getString("admin", "UpdateExtensions","network"), 3881 getDateTime("created",null), 3882 getString("admin", "UpdateExtensions","_type") 3883 )); 3884 3885 3886 3887 3888 store(); 3889 //adminSync.broadcast(attributes, config); 3890 } 3891 3892 private void doUpdateExtensionProvider() throws PageException { 3893 admin.updateExtensionProvider( 3894 getString("admin", "UpdateExtensionProvider","url") 3895 ); 3896 store(); 3897 } 3898 3899 private void doUpdateExtensionInfo() throws PageException { 3900 admin.updateExtensionInfo( 3901 getBool("admin", "UpdateExtensionInfo","enabled") 3902 ); 3903 store(); 3904 } 3905 3906 private void doVerifyExtensionProvider() throws PageException { 3907 admin.verifyExtensionProvider(getString("admin", "VerifyExtensionProvider","url")); 3908 3909 } 3910 private void doResetId() throws PageException { 3911 admin.resetId(); 3912 store(); 3913 3914 } 3915 3916 private void doRemoveExtensionProvider() throws PageException { 3917 admin.removeExtensionProvider(getString("admin", "RemoveExtensionProvider","url")); 3918 store(); 3919 } 3920 3921 /** 3922 * @throws PageException 3923 * 3924 */ 3925 private void doGetApplicationSetting() throws PageException { 3926 3927 Struct sct=new StructImpl(); 3928 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 3929 sct.set("scriptProtect",AppListenerUtil.translateScriptProtect(config.getScriptProtect())); 3930 3931 // request timeout 3932 sct.set("requestTimeout",config.getRequestTimeout()); 3933 sct.set("requestTimeout_day",Caster.toInteger(config.getRequestTimeout().getDay())); 3934 sct.set("requestTimeout_hour",Caster.toInteger(config.getRequestTimeout().getHour())); 3935 sct.set("requestTimeout_minute",Caster.toInteger(config.getRequestTimeout().getMinute())); 3936 sct.set("requestTimeout_second",Caster.toInteger(config.getRequestTimeout().getSecond())); 3937 3938 // AllowURLRequestTimeout 3939 sct.set("AllowURLRequestTimeout",Caster.toBoolean(config.isAllowURLRequestTimeout()));// DIF 23 3940 } 3941 3942 private void doGetOutputSetting() throws PageException { 3943 3944 Struct sct=new StructImpl(); 3945 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 3946 sct.set("suppressContent",Caster.toBoolean(config.isSuppressContent())); 3947 sct.set("contentLength",Caster.toBoolean(config.contentLength())); 3948 //sct.set("showVersion",Caster.toBoolean(config.isShowVersion())); 3949 sct.set("allowCompression",Caster.toBoolean(config.allowCompression())); 3950 int wt = config.getCFMLWriterType(); 3951 String cfmlWriter="regular"; 3952 if(wt==ConfigImpl.CFML_WRITER_WS) cfmlWriter="white-space"; 3953 else if(wt==ConfigImpl.CFML_WRITER_WS_PREF) cfmlWriter="white-space-pref"; 3954 3955 sct.set("cfmlWriter",cfmlWriter); 3956 sct.set("bufferOutput",Caster.toBoolean(config.getBufferOutput())); 3957 3958 } 3959 3960 /** 3961 * @throws PageException 3962 * 3963 */ 3964 private void doGetScope() throws PageException { 3965 String sessionType=config.getSessionType()==Config.SESSION_TYPE_J2EE?"j2ee":"cfml"; 3966 String localMode=AppListenerUtil.toLocalMode(config.getLocalMode(),"classic"); 3967 3968 3969 Struct sct=new StructImpl(); 3970 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 3971 sct.set("allowImplicidQueryCall",Caster.toBoolean(config.allowImplicidQueryCall())); 3972 sct.set("mergeFormAndUrl",Caster.toBoolean(config.mergeFormAndURL())); 3973 3974 sct.set("sessiontype",sessionType); 3975 sct.set("localmode",localMode); 3976 sct.set("sessionManagement",Caster.toBoolean(config.isSessionManagement())); 3977 sct.set("clientManagement",Caster.toBoolean(config.isClientManagement())); 3978 sct.set("domainCookies",Caster.toBoolean(config.isDomainCookies())); 3979 sct.set("clientCookies",Caster.toBoolean(config.isClientCookies())); 3980 3981 TimeSpan ts=config.getSessionTimeout(); 3982 sct.set("sessionTimeout",ts); 3983 sct.set("sessionTimeout_day",Caster.toInteger(ts.getDay())); 3984 sct.set("sessionTimeout_hour",Caster.toInteger(ts.getHour())); 3985 sct.set("sessionTimeout_minute",Caster.toInteger(ts.getMinute())); 3986 sct.set("sessionTimeout_second",Caster.toInteger(ts.getSecond())); 3987 3988 ts=config.getApplicationTimeout(); 3989 sct.set("applicationTimeout",ts); 3990 sct.set("applicationTimeout_day",Caster.toInteger(ts.getDay())); 3991 sct.set("applicationTimeout_hour",Caster.toInteger(ts.getHour())); 3992 sct.set("applicationTimeout_minute",Caster.toInteger(ts.getMinute())); 3993 sct.set("applicationTimeout_second",Caster.toInteger(ts.getSecond())); 3994 3995 ts=config.getClientTimeout(); 3996 sct.set("clientTimeout",ts); 3997 sct.set("clientTimeout_day",Caster.toInteger(ts.getDay())); 3998 sct.set("clientTimeout_hour",Caster.toInteger(ts.getHour())); 3999 sct.set("clientTimeout_minute",Caster.toInteger(ts.getMinute())); 4000 sct.set("clientTimeout_second",Caster.toInteger(ts.getSecond())); 4001 4002 4003 // scope cascading type 4004 if(config.getScopeCascadingType()==Config.SCOPE_STRICT) sct.set("scopeCascadingType","strict"); 4005 else if(config.getScopeCascadingType()==Config.SCOPE_SMALL) sct.set("scopeCascadingType","small"); 4006 else if(config.getScopeCascadingType()==Config.SCOPE_STANDARD) sct.set("scopeCascadingType","standard"); 4007 } 4008 4009 /** 4010 * @throws PageException 4011 * 4012 */ 4013 private void doUpdateComponent() throws PageException { 4014 4015 admin.updateComponentDeepSearch(getBoolObject("admin", action, "deepSearch")); 4016 admin.updateBaseComponent(getString("admin",action,"baseComponentTemplate")); 4017 admin.updateComponentDumpTemplate(getString("admin",action,"componentDumpTemplate")); 4018 admin.updateComponentDataMemberDefaultAccess(getString("admin",action,"componentDataMemberDefaultAccess")); 4019 admin.updateTriggerDataMember(getBoolObject("admin",action,"triggerDataMember")); 4020 admin.updateComponentUseShadow(getBoolObject("admin",action,"useShadow")); 4021 admin.updateComponentDefaultImport(getString("admin",action,"componentDefaultImport")); 4022 admin.updateComponentLocalSearch(getBoolObject("admin",action,"componentLocalSearch")); 4023 admin.updateComponentPathCache(getBoolObject("admin",action,"componentPathCache")); 4024 store(); 4025 adminSync.broadcast(attributes, config); 4026 } 4027 4028 /** 4029 * @throws PageException 4030 * @throws PageException 4031 * 4032 */ 4033 private void doGetComponent() throws PageException { 4034 Struct sct=new StructImpl(); 4035 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 4036 // Base Component 4037 try { 4038 PageSource ps = ((PageContextImpl)pageContext).getPageSourceExisting(config.getBaseComponentTemplate()); 4039 if(ps!=null) sct.set("baseComponentTemplate",ps.getDisplayPath()); 4040 else sct.set("baseComponentTemplate",""); 4041 } catch (PageException e) { 4042 sct.set("baseComponentTemplate",""); 4043 } 4044 sct.set("strBaseComponentTemplate",config.getBaseComponentTemplate()); 4045 4046 // dump template 4047 try { 4048 PageSource ps = ((PageContextImpl)pageContext).getPageSourceExisting(config.getComponentDumpTemplate()); 4049 if(ps!=null) sct.set("componentDumpTemplate",ps.getDisplayPath()); 4050 else sct.set("componentDumpTemplate",""); 4051 } catch (PageException e) { 4052 sct.set("componentDumpTemplate",""); 4053 } 4054 sct.set("strComponentDumpTemplate",config.getComponentDumpTemplate()); 4055 4056 sct.set("deepSearch",Caster.toBoolean(config.doComponentDeepSearch())); 4057 sct.set("componentDataMemberDefaultAccess",ComponentUtil.toStringAccess(config.getComponentDataMemberDefaultAccess())); 4058 sct.set("triggerDataMember",Caster.toBoolean(config.getTriggerComponentDataMember())); 4059 sct.set("useShadow",Caster.toBoolean(config.useComponentShadow())); 4060 sct.set("ComponentDefaultImport",config.getComponentDefaultImport()); 4061 sct.set("componentLocalSearch",config.getComponentLocalSearch()); 4062 sct.set("componentPathCache",config.useComponentPathCache()); 4063 4064 } 4065 4066 /** 4067 * @throws PageException 4068 * 4069 */ 4070 private void doUpdateRegional() throws PageException { 4071 Boolean useTimeServer=getBool("usetimeserver",null); 4072 4073 try{ 4074 admin.updateLocale(getString("admin",action,"locale")); 4075 admin.updateTimeZone(getString("admin",action,"timezone")); 4076 admin.updateTimeServer(getString("admin",action,"timeserver"),useTimeServer); 4077 admin.updateTimeZone(getString("admin",action,"timezone")); 4078 } 4079 finally { 4080 store(); 4081 } 4082 adminSync.broadcast(attributes, config); 4083 } 4084 private void doUpdateMonitorEnabled() throws PageException { 4085 4086 try{ 4087 admin.updateMonitorEnabled(getBool("admin","UpdateMonitorEnabled","monitorEnabled")); 4088 } 4089 finally { 4090 store(); 4091 } 4092 adminSync.broadcast(attributes, config); 4093 } 4094 4095 4096 4097 private void doUpdateTLD() throws PageException { 4098 try { 4099 String jar = getString("jar",null); 4100 if(!StringUtil.isEmpty(jar,true)){ 4101 Resource resJar = ResourceUtil.toResourceExisting(pageContext, jar); 4102 admin.updateJar(resJar); 4103 } 4104 Resource resTld = ResourceUtil.toResourceExisting(pageContext, getString("admin",action,"tld")); 4105 admin.updateTLD(resTld); 4106 } 4107 catch (Exception e) { 4108 throw Caster.toPageException(e); 4109 } 4110 store(); 4111 } 4112 private void doUpdateFLD() throws PageException { 4113 try { 4114 String jar = getString("jar",null); 4115 if(!StringUtil.isEmpty(jar,true)){ 4116 Resource resJar = ResourceUtil.toResourceExisting(pageContext, jar); 4117 admin.updateJar(resJar); 4118 } 4119 Resource resFld = ResourceUtil.toResourceExisting(pageContext, getString("admin",action,"fld")); 4120 admin.updateFLD(resFld); 4121 } 4122 catch (Exception e) { 4123 throw Caster.toPageException(e); 4124 } 4125 store(); 4126 } 4127 4128 private void doUpdateJar() throws PageException { 4129 try { 4130 Resource resJar = ResourceUtil.toResourceExisting(pageContext, getString("admin",action,"jar")); 4131 admin.updateJar(resJar); 4132 } 4133 catch (Exception e) { 4134 throw Caster.toPageException(e); 4135 } 4136 store(); 4137 } 4138 4139 4140 4141 4142 4143 private void doUpdateLoginSettings() throws PageException { 4144 boolean captcha = getBool("admin", "UpdateLoginSettings", "captcha"); 4145 int delay = getInt("admin", "UpdateLoginSettings", "delay"); 4146 admin.updateLoginSettings(captcha,delay); 4147 store(); 4148 } 4149 4150 4151 4152 private void doUpdateSSLCertificate() throws PageException { 4153 String host=getString("admin", "UpdateSSLCertificateInstall", "host"); 4154 int port = getInt("port", 443); 4155 updateSSLCertificate(config, host, port); 4156 } 4157 4158 public static void updateSSLCertificate(Config config,String host, int port) throws PageException { 4159 Resource cacerts=config.getSecurityDirectory(); 4160 4161 try { 4162 CertificateInstaller installer = new CertificateInstaller(cacerts,host,port); 4163 installer.installAll(); 4164 } catch (Exception e) { 4165 throw Caster.toPageException(e); 4166 } 4167 } 4168 4169 private void doGetSSLCertificate() throws PageException { 4170 String host=getString("admin", "GetSSLCertificate", "host"); 4171 int port = getInt("port", 443); 4172 pageContext.setVariable(getString("admin",action,"returnVariable"),getSSLCertificate(config,host,port)); 4173 } 4174 4175 public static Query getSSLCertificate(Config config,String host, int port) throws PageException { 4176 Resource cacerts=config.getSecurityDirectory(); 4177 CertificateInstaller installer; 4178 try { 4179 installer = new CertificateInstaller(cacerts,host,port); 4180 } catch (Exception e) { 4181 throw Caster.toPageException(e); 4182 } 4183 X509Certificate[] certs = installer.getCertificates(); 4184 X509Certificate cert; 4185 4186 Query qry=new QueryImpl(new String[]{"subject","issuer"},certs.length,"certificates"); 4187 for(int i=0;i<certs.length;i++){ 4188 cert=certs[i]; 4189 qry.setAtEL("subject",i+1, cert.getSubjectDN().getName()); 4190 qry.setAtEL("issuer",i+1, cert.getIssuerDN().getName()); 4191 } 4192 return qry; 4193 } 4194 4195 private void doRemoveJar() throws PageException { 4196 try { 4197 String name = getString("jar",null); 4198 if(StringUtil.isEmpty(name))name=getString("admin",action,"name"); 4199 4200 admin.removeJar(name); 4201 } 4202 catch (Exception e) { 4203 throw Caster.toPageException(e); 4204 } 4205 store(); 4206 } 4207 4208 private void doRemoveTLD() throws PageException { 4209 try { 4210 String name = getString("tld",null); 4211 if(StringUtil.isEmpty(name))name=getString("admin",action,"name"); 4212 admin.removeTLD(name); 4213 } 4214 catch (Exception e) { 4215 throw Caster.toPageException(e); 4216 } 4217 store(); 4218 } 4219 4220 4221 4222 private void doRemoveFLD() throws PageException { 4223 try { 4224 String name = getString("fld",null); 4225 if(StringUtil.isEmpty(name))name=getString("admin",action,"name"); 4226 admin.removeFLD(name); 4227 } 4228 catch (Exception e) { 4229 throw Caster.toPageException(e); 4230 } 4231 store(); 4232 } 4233 4234 private void doUpdateRemoteClient() throws PageException { 4235 4236 4237 4238 admin.updateRemoteClient( 4239 getString("admin",action,"label"), 4240 getString("admin",action,"url"), 4241 getString("admin",action,"remotetype"), 4242 getString("admin",action,"securityKey"), 4243 getString("admin",action,"usage"), 4244 getString("admin",action,"adminPassword"), 4245 getString("ServerUsername",""), 4246 getString("ServerPassword",""), 4247 getString("proxyServer",""), 4248 getString("proxyUsername",""), 4249 getString("proxyPassword",""), 4250 getString("proxyPort","") 4251 4252 ); 4253 4254 store(); 4255 } 4256 private void doUpdateRemoteClientUsage() throws PageException { 4257 admin.updateRemoteClientUsage( 4258 getString("admin",action,"code"), 4259 getString("admin",action,"displayname") 4260 4261 ); 4262 store(); 4263 } 4264 private void doRemoveRemoteClientUsage() throws PageException { 4265 admin.removeRemoteClientUsage( 4266 getString("admin",action,"code") 4267 4268 ); 4269 store(); 4270 } 4271 4272 private String getCallerId() throws IOException { 4273 if(type==TYPE_WEB) { 4274 return config.getId(); 4275 //return GetRailoId.createId(config.getId(), config.getConfigDir()); 4276 } 4277 if(config instanceof ConfigWebImpl){ 4278 ConfigWebImpl cwi = (ConfigWebImpl)config; 4279 return cwi.getServerId(); 4280 //return GetRailoId.createId(cwi.getServerId(), cwi.getServerConfigDir()); 4281 } 4282 if(config instanceof ConfigServer){ 4283 return config.getId(); 4284 //return GetRailoId.createId(config.getId(), config.getConfigDir()); 4285 } 4286 throw new IOException("can not create id"); 4287 } 4288 4289 private void doUpdateApplicationListener() throws PageException { 4290 admin.updateApplicationListener( 4291 getString("admin",action,"listenerType"), 4292 getString("admin",action,"listenerMode") 4293 ); 4294 4295 store(); 4296 adminSync.broadcast(attributes, config); 4297 } 4298 4299 4300 4301 private void doUpdateProxy() throws PageException { 4302 admin.updateProxy( 4303 getBool("admin",action,"proxyenabled"), 4304 getString("admin",action,"proxyserver"), 4305 getInt("admin",action,"proxyport"), 4306 getString("admin",action,"proxyusername"), 4307 getString("admin",action,"proxypassword") 4308 ); 4309 store(); 4310 } 4311 4312 4313 private void doUpdateCharset() throws PageException { 4314 admin.updateResourceCharset(getString("admin",action,"resourceCharset")); 4315 admin.updateTemplateCharset(getString("admin",action,"templateCharset")); 4316 admin.updateWebCharset(getString("admin",action,"webCharset")); 4317 store(); 4318 adminSync.broadcast(attributes, config); 4319 } 4320 4321 /** 4322 * @throws PageException 4323 * 4324 */ 4325 private void doSecurityManager() throws PageException { 4326 String rtnVar = getString("admin",action,"returnVariable"); 4327 String secType = getString("admin",action,"sectype"); 4328 String secValue = getString("secvalue",null); 4329 boolean isServer=config instanceof ConfigServer; 4330 4331 if(secValue==null) { 4332 if(isServer) { 4333 pageContext.setVariable( 4334 rtnVar, 4335 SecurityManagerImpl.toStringAccessValue(SecurityManager.VALUE_YES) 4336 ); 4337 } 4338 else { 4339 pageContext.setVariable( 4340 rtnVar, 4341 SecurityManagerImpl.toStringAccessValue(config.getSecurityManager().getAccess(secType)) 4342 ); 4343 } 4344 return; 4345 } 4346 pageContext.setVariable( 4347 rtnVar, 4348 Caster.toBoolean( 4349 isServer || 4350 config.getSecurityManager().getAccess(secType) == SecurityManagerImpl.toShortAccessValue(secValue) 4351 ) 4352 ); 4353 } 4354 4355 /** 4356 * @throws PageException 4357 * 4358 */ 4359 private void doGetTimeZones() throws PageException { 4360 4361 4362 4363 String strLocale=getString("locale","english (united kingdom)"); 4364 Locale locale = LocaleFactory.getLocale(strLocale); 4365 4366 String[] timeZones = TimeZone.getAvailableIDs(); 4367 railo.runtime.type.Query qry=new QueryImpl(new String[]{"id","display"},new String[]{"varchar","varchar"},timeZones.length,"timezones"); 4368 Arrays.sort(timeZones); 4369 TimeZone timeZone; 4370 for(int i=0;i<timeZones.length;i++) { 4371 timeZone=TimeZone.getTimeZone(timeZones[i]); 4372 qry.setAt("id",i+1,timeZones[i]); 4373 qry.setAt("display",i+1,timeZone.getDisplayName(locale)); 4374 4375 } 4376 pageContext.setVariable(getString("admin",action,"returnVariable"),qry); 4377 } 4378 4379 /** 4380 * @throws PageException 4381 * 4382 */ 4383 private void doGetLocales() throws PageException { 4384 Struct sct=new StructImpl(StructImpl.TYPE_LINKED); 4385 //Array arr=new ArrayImpl(); 4386 String strLocale=getString("locale","english (united kingdom)"); 4387 Locale locale = LocaleFactory.getLocale(strLocale); 4388 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 4389 Map locales = LocaleFactory.getLocales(); 4390 Iterator it = locales.keySet().iterator(); 4391 4392 String key; 4393 Locale l; 4394 while(it.hasNext()) { 4395 key=(String)it.next(); 4396 l=(Locale) locales.get(key); 4397 sct.setEL(l.toString(),l.getDisplayName(locale)); 4398 //arr.append(locale.getDisplayName()); 4399 } 4400 //arr.sort("textnocase","asc"); 4401 } 4402 4403 4404 private void doGetApplicationListener() throws PageException { 4405 Struct sct=new StructImpl(); 4406 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 4407 ApplicationListener appListener = config.getApplicationListener(); 4408 sct.set("type",AppListenerUtil.toStringType(appListener)); 4409 sct.set("mode",AppListenerUtil.toStringMode(appListener.getMode())); 4410 // replaced with encoding outputsct.set("defaultencoding", config.get DefaultEncoding()); 4411 } 4412 /** 4413 * @throws PageException 4414 * 4415 */ 4416 private void doGetRegional() throws PageException { 4417 Struct sct=new StructImpl(); 4418 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 4419 sct.set("locale",Caster.toString(config.getLocale())); 4420 sct.set("timezone",toStringTimeZone(pageContext.getTimeZone())); 4421 sct.set("timeserver",config.getTimeServer()); 4422 sct.set("usetimeserver",config.getUseTimeServer()); 4423 // replaced with encoding outputsct.set("defaultencoding", config.get DefaultEncoding()); 4424 } 4425 private void doIsMonitorEnabled() throws PageException { 4426 if(config instanceof ConfigServerImpl) { 4427 ConfigServerImpl cs=(ConfigServerImpl) config; 4428 pageContext.setVariable(getString("admin",action,"returnVariable"),Caster.toBoolean(cs.isMonitoringEnabled())); 4429 } 4430 } 4431 4432 4433 private void doSurveillance() throws PageException { 4434 // Server 4435 if(config instanceof ConfigServer) { 4436 ConfigServer cs=(ConfigServer) config; 4437 ConfigWeb[] webs = cs.getConfigWebs(); 4438 Struct sct=new StructImpl(); 4439 for(int i=0;i<webs.length;i++){ 4440 ConfigWebImpl cw=(ConfigWebImpl) webs[i]; 4441 try{ 4442 sct.setEL(cw.getLabel(), ((CFMLFactoryImpl)cw.getFactory()).getInfo()); 4443 } 4444 catch(Throwable t){} 4445 } 4446 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 4447 4448 } 4449 // Web 4450 else { 4451 CFMLFactoryImpl factory = (CFMLFactoryImpl) config.getFactory(); 4452 pageContext.setVariable(getString("admin",action,"returnVariable"), 4453 factory.getInfo()); 4454 } 4455 } 4456 4457 private void doStopThread() throws PageException { 4458 String contextId=getString("admin", "stopThread", "contextId"); 4459 String threadId=getString("admin", "stopThread", "threadId"); 4460 String stopType=getString("stopType","exception"); 4461 4462 if(!(config instanceof ConfigServer)) 4463 throw new ApplicationException("invalid context for this action"); 4464 4465 4466 ConfigServer cs=(ConfigServer) config; 4467 ConfigWeb[] webs = cs.getConfigWebs(); 4468 for(int i=0;i<webs.length;i++){ 4469 ConfigWebImpl cw=(ConfigWebImpl) webs[i]; 4470 if(!cw.getId().equals(contextId)) continue; 4471 ((CFMLFactoryImpl)cw.getFactory()).stopThread(threadId,stopType); 4472 break; 4473 4474 } 4475 } 4476 4477 private void doHeapDump() throws PageException { 4478 String strDestination = getString( "admin", action, "destination" ); 4479 boolean live = getBoolV( "live" ,true); 4480 Resource destination = ResourceUtil.toResourceNotExisting(pageContext, strDestination); 4481 try { 4482 HeapDumper.dumpTo(destination, live); 4483 } catch (IOException e) { 4484 throw Caster.toPageException(e); 4485 } 4486 } 4487 4488 private void doGetProxy() throws PageException { 4489 Struct sct=new StructImpl(); 4490 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 4491 ProxyData pd = config.getProxyData(); 4492 String port=pd==null || pd.getPort()<=0?"":Caster.toString(pd.getPort()); 4493 4494 //sct.set("enabled",Caster.toBoolean(config.isProxyEnable())); 4495 sct.set("port",port); 4496 sct.set("server",pd==null?"":emptyIfNull(pd.getServer())); 4497 sct.set("username",pd==null?"":emptyIfNull(pd.getUsername())); 4498 sct.set("password",pd==null?"":emptyIfNull(pd.getPassword())); 4499 } 4500 4501 4502 4503 private void doGetLoginSettings() throws ApplicationException, PageException { 4504 Struct sct=new StructImpl(); 4505 ConfigImpl c = (ConfigImpl) ThreadLocalPageContext.getConfig(config); 4506 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 4507 sct.set("captcha",Caster.toBoolean(c.getLoginCaptcha())); 4508 sct.set("delay",Caster.toDouble(c.getLoginDelay())); 4509 4510 } 4511 4512 4513 private void doGetCharset() throws PageException { 4514 Struct sct=new StructImpl(); 4515 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 4516 sct.set("resourceCharset",config.getResourceCharset()); 4517 sct.set("templateCharset",config.getTemplateCharset()); 4518 sct.set("webCharset",config.getWebCharset()); 4519 sct.set("jreCharset",SystemUtil.getCharset()); 4520 } 4521 4522 /** 4523 * @throws PageException 4524 * 4525 */ 4526 private void doGetUpdate() throws PageException { 4527 Struct sct=new StructImpl(); 4528 pageContext.setVariable(getString("admin",action,"returnVariable"),sct); 4529 URL location = config.getUpdateLocation(); 4530 if(location==null) { 4531 try { 4532 location=new URL("http://www.getrailo.org"); 4533 } 4534 catch (MalformedURLException e) {} 4535 } 4536 String type=config.getUpdateType(); 4537 if(StringUtil.isEmpty(type))type="manual"; 4538 4539 sct.set("location",location.toExternalForm()); 4540 sct.set("type",type); 4541 4542 } 4543 4544 4545 /** 4546 * @throws PageException 4547 * 4548 */ 4549 private synchronized void store() throws PageException { 4550 try { 4551 admin.store(); 4552 } catch (Exception e) { 4553 throw Caster.toPageException(e); 4554 } 4555 } 4556 private String getString(String tagName, String actionName, String attributeName) throws ApplicationException { 4557 return getString(tagName, actionName, attributeName,true); 4558 } 4559 4560 private String getString(String tagName, String actionName, String attributeName,boolean trim) throws ApplicationException { 4561 String value=getString(attributeName,null); 4562 if(value==null) throw new ApplicationException("Attribute ["+attributeName+"] for tag ["+tagName+"] is required if attribute action has the value ["+actionName+"]"); 4563 return trim?value.trim():value; 4564 } 4565 4566 private double getDouble(String tagName, String actionName, String attributeName) throws ApplicationException { 4567 double value=getDouble(attributeName,Double.NaN); 4568 if(!Decision.isValid(value)) throw new ApplicationException("Attribute ["+attributeName+"] for tag ["+tagName+"] is required if attribute action has the value ["+actionName+"]"); 4569 return value; 4570 } 4571 4572 private String getString(String attributeName, String defaultValue) { 4573 Object value=attributes.get(attributeName,null); 4574 if(value==null)return defaultValue; 4575 return Caster.toString(value,null); 4576 } 4577 4578 private DateTime getDateTime(String attributeName, DateTime defaultValue) { 4579 Object value=attributes.get(attributeName,null); 4580 if(value==null)return defaultValue; 4581 return DateCaster.toDateAdvanced(value, null, defaultValue); 4582 } 4583 4584 private Object getObject(String attributeName, Object defaultValue) { 4585 return attributes.get(attributeName,defaultValue); 4586 } 4587 4588 private boolean getBool(String tagName, String actionName, String attributeName) throws PageException { 4589 Object value=attributes.get(attributeName,null); 4590 if(value==null) 4591 throw new ApplicationException("Attribute ["+attributeName+"] for tag ["+tagName+"] is required if attribute action has the value ["+actionName+"]"); 4592 return Caster.toBooleanValue(value); 4593 } 4594 private Boolean getBoolObject(String tagName, String actionName, String attributeName) throws PageException { 4595 Object value=attributes.get(attributeName,null); 4596 if(value==null) 4597 throw new ApplicationException("Attribute ["+attributeName+"] for tag ["+tagName+"] is required if attribute action has the value ["+actionName+"]"); 4598 if(StringUtil.isEmpty(value)) return null; 4599 return Caster.toBoolean(value); 4600 } 4601 4602 private Object getObject(String tagName, String actionName, String attributeName) throws PageException { 4603 Object value=attributes.get(attributeName,null); 4604 if(value==null) 4605 throw new ApplicationException("Attribute ["+attributeName+"] for tag ["+tagName+"] is required if attribute action has the value ["+actionName+"]"); 4606 return value; 4607 } 4608 4609 private boolean getBoolV(String attributeName, boolean defaultValue) { 4610 Object value=attributes.get(attributeName,null); 4611 if(value==null) return defaultValue; 4612 return Caster.toBooleanValue(value,defaultValue); 4613 } 4614 4615 private Boolean getBool(String attributeName, Boolean defaultValue) { 4616 Object value=attributes.get(attributeName,null); 4617 if(value==null) return defaultValue; 4618 return Caster.toBoolean(value,defaultValue); 4619 } 4620 4621 private Struct getStruct(String attributeName, Struct defaultValue) { 4622 Object value=attributes.get(attributeName,null); 4623 if(value==null) return defaultValue; 4624 try { 4625 return Caster.toStruct(value); 4626 } catch (PageException e) { 4627 return defaultValue; 4628 } 4629 } 4630 4631 private Struct getStruct(String tagName, String actionName, String attributeName) throws PageException { 4632 Object value=attributes.get(attributeName,null); 4633 if(value==null) 4634 throw new ApplicationException("Attribute ["+attributeName+"] for tag ["+tagName+"] is required if attribute action has the value ["+actionName+"]"); 4635 return Caster.toStruct(value); 4636 } 4637 4638 private int getInt(String tagName, String actionName, String attributeName) throws PageException { 4639 Object value=attributes.get(attributeName,null); 4640 if(value==null) 4641 throw new ApplicationException("Attribute ["+attributeName+"] for tag ["+tagName+"] is required if attribute action has the value ["+actionName+"]"); 4642 return (int)Caster.toDoubleValue(value); 4643 } 4644 4645 private int getInt(String attributeName, int defaultValue) { 4646 Object value=attributes.get(attributeName,null); 4647 if(value==null) return defaultValue; 4648 return Caster.toIntValue(value,defaultValue); 4649 } 4650 private long getLong(String attributeName, long defaultValue) { 4651 Object value=attributes.get(attributeName,null); 4652 if(value==null) return defaultValue; 4653 return Caster.toLongValue(value,defaultValue); 4654 } 4655 4656 private double getDouble(String attributeName, double defaultValue) { 4657 Object value=attributes.get(attributeName,null); 4658 if(value==null) return defaultValue; 4659 return Caster.toDoubleValue(value,defaultValue); 4660 } 4661 4662 private TimeSpan getTimespan(String tagName, String actionName, String attributeName) throws PageException { 4663 Object value=attributes.get(attributeName,null); 4664 if(value==null) 4665 throw new ApplicationException("Attribute ["+attributeName+"] for tag ["+tagName+"] is required if attribute action has the value ["+actionName+"]"); 4666 if(StringUtil.isEmpty(value))return null; 4667 return Caster.toTimespan(value); 4668 } 4669 4670 private Object emptyIfNull(String str) { 4671 if(str==null) return ""; 4672 return str; 4673 } 4674 4675 private void throwNoAccessWhenWeb() throws ApplicationException { 4676 if(type==TYPE_WEB)throw new ApplicationException( 4677 "you have no access for action [web."+action+"]"); 4678 } 4679 4680 private void throwNoAccessWhenServer() throws ApplicationException { 4681 if(type==TYPE_SERVER) { 4682 throw new ApplicationException( 4683 "you have no access for action [server."+action+"]"); 4684 } 4685 } 4686 } 4687 4688 4689 4690 4691 4692 final class PluginFilter implements ResourceFilter { 4693 @Override 4694 public boolean accept(Resource res) { 4695 return doAccept(res); 4696 } 4697 4698 public static boolean doAccept(Resource res) { 4699 return res.isDirectory() && res.getRealResource("/Action.cfc").isFile() && res.getRealResource("/language.xml").isFile(); 4700 } 4701 4702 }