001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.services; 020 021 022import java.util.Map; 023 024import lucee.runtime.db.DataSource; 025import lucee.runtime.op.Caster; 026import lucee.runtime.type.Struct; 027import lucee.runtime.type.StructImpl; 028import lucee.runtime.type.util.KeyConstants; 029import coldfusion.sql.DataSourceDef; 030 031public class DatSourceDefImpl implements DataSourceDef { 032 033 private DataSource ds; 034 035 public DatSourceDefImpl(DataSource ds) { 036 this.ds=ds; 037 } 038 039 public Object get(Object arg1) { 040 // TODO Auto-generated method stub 041 return null; 042 } 043 044 public Struct getAllowedSQL() { 045 Struct allow=new StructImpl(); 046 allow.setEL(KeyConstants._alter, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_ALTER))); 047 allow.setEL(KeyConstants._create, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_CREATE))); 048 allow.setEL(KeyConstants._delete, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_DELETE))); 049 allow.setEL(KeyConstants._drop, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_DROP))); 050 allow.setEL(KeyConstants._grant, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_GRANT))); 051 allow.setEL(KeyConstants._insert, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_INSERT))); 052 allow.setEL(KeyConstants._revoke, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_REVOKE))); 053 allow.setEL(KeyConstants._select, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_SELECT))); 054 allow.setEL("storedproc", Caster.toBoolean(true));// TODO 055 allow.setEL(KeyConstants._update, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_UPDATE))); 056 return allow; 057 } 058 059 @Override 060 public String getClassName() { 061 return ds.getClazz().getName(); 062 } 063 064 @Override 065 public String getDatabase() { 066 return ds.getDatabase(); 067 } 068 069 @Override 070 public String getDesc() { 071 return ""; 072 } 073 074 public String getDriver() { 075 return ""; 076 } 077 078 public String getDsn() { 079 return ds.getDsnTranslated(); 080 } 081 082 public Struct getExtraData() { 083 Struct rtn=new StructImpl(); 084 Struct connprop=new StructImpl(); 085 String[] names = ds.getCustomNames(); 086 rtn.setEL("connectionprops", connprop); 087 for(int i=0;i<names.length;i++) { 088 connprop.setEL(names[i], ds.getCustomValue(names[i])); 089 } 090 rtn.setEL("maxpooledstatements",new Double(1000) ); 091 rtn.setEL("sid",""); 092 rtn.setEL("timestampasstring", Boolean.FALSE); 093 rtn.setEL("useTrustedConnection", Boolean.FALSE); 094 rtn.setEL("datasource",ds.getName() ); 095 rtn.setEL("_port",new Double(ds.getPort()) ); 096 rtn.setEL("port",new Double(ds.getPort()) ); 097 rtn.setEL("_logintimeout",new Double(30) ); 098 rtn.setEL("args", ""); 099 rtn.setEL("databaseFile", ""); 100 rtn.setEL("defaultpassword","" ); 101 rtn.setEL("defaultusername", ""); 102 rtn.setEL("host",ds.getHost() ); 103 rtn.setEL("maxBufferSize",new Double(0) ); 104 rtn.setEL("pagetimeout",new Double(0) ); 105 rtn.setEL("selectMethod","direct" ); 106 rtn.setEL("sendStringParamterAsUnicode",Boolean.TRUE ); 107 rtn.setEL("systemDatabaseFile", ""); 108 109 110 return rtn; 111 } 112 113 @Override 114 public String getHost() { 115 return ds.getHost(); 116 } 117 118 public String getIfxSrv() { 119 return ""; 120 } 121 122 public int getInterval() { 123 return 0; 124 } 125 126 public String getJNDIName() { 127 return ""; 128 } 129 130 @Override 131 public String getJndiName() { 132 return getJNDIName(); 133 } 134 135 public Struct getJndienv() { 136 return new StructImpl(); 137 } 138 139 public int getLoginTimeout() { 140 return ds.getConnectionTimeout(); 141 } 142 143 @Override 144 public int getLogintimeout() { 145 return getLoginTimeout(); 146 } 147 148 public int getMaxBlobSize() { 149 return 64000; 150 } 151 152 public int getMaxClobSize() { 153 return 64000; 154 } 155 156 public int getMaxConnections() { 157 return ds.getConnectionLimit(); 158 } 159 160 public int getMaxPooledStatements() { 161 return 0; 162 } 163 164 public int getMaxconnections() { 165 return getMaxConnections(); 166 } 167 168 @Override 169 public int getPort() { 170 return ds.getPort(); 171 } 172 173 public String getSelectMethod() { 174 return ""; 175 } 176 177 public String getSid() { 178 return ""; 179 } 180 181 public boolean getStrPrmUni() { 182 return false; 183 } 184 185 public int getTimeout() { 186 return ds.getConnectionTimeout(); 187 } 188 189 public int getType() { 190 return 0; 191 } 192 193 @Override 194 public String getUrl() { 195 return ds.getDsnTranslated(); 196 } 197 198 @Override 199 public String getUsername() { 200 return ds.getUsername(); 201 } 202 203 @Override 204 public String getVendor() { 205 return ""; 206 } 207 208 @Override 209 public boolean isBlobEnabled() { 210 return ds.isBlob(); 211 } 212 213 @Override 214 public boolean isClobEnabled() { 215 return ds.isClob(); 216 } 217 218 public boolean isConnectionEnabled() { 219 return true; 220 } 221 222 public boolean isDynamic() { 223 return false; 224 } 225 226 public boolean isPooling() { 227 return true; 228 } 229 230 public boolean isRemoveOnPageEnd() { 231 return false; 232 } 233 234 public boolean isSQLRestricted() { 235 return false; 236 } 237 238 public void setAllowedSQL(Struct arg1) { 239 // TODO Auto-generated method stub 240 241 } 242 243 public void setBlobEnabled(boolean arg1) { 244 // TODO Auto-generated method stub 245 246 } 247 248 public void setClassName(String arg1) { 249 // TODO Auto-generated method stub 250 251 } 252 253 public void setClobEnabled(boolean arg1) { 254 // TODO Auto-generated method stub 255 256 } 257 258 public void setConnectionEnabled(boolean arg1) { 259 // TODO Auto-generated method stub 260 261 } 262 263 public void setDatabase(String arg1) { 264 // TODO Auto-generated method stub 265 266 } 267 268 public void setDesc(String arg1) { 269 // TODO Auto-generated method stub 270 271 } 272 273 public void setDriver(String arg1) { 274 // TODO Auto-generated method stub 275 276 } 277 278 public void setDsn(String arg1) { 279 // TODO Auto-generated method stub 280 281 } 282 283 public void setDynamic(boolean arg1) { 284 // TODO Auto-generated method stub 285 286 } 287 288 public void setExtraData(Struct arg1) { 289 // TODO Auto-generated method stub 290 291 } 292 293 public void setHost(String arg1) { 294 // TODO Auto-generated method stub 295 296 } 297 298 public void setIfxSrv(String arg1) { 299 // TODO Auto-generated method stub 300 301 } 302 303 public void setInterval(int arg1) { 304 // TODO Auto-generated method stub 305 306 } 307 308 public void setJNDIName(String arg1) { 309 // TODO Auto-generated method stub 310 311 } 312 313 public void setJndiName(String arg1) { 314 // TODO Auto-generated method stub 315 316 } 317 318 public void setJndienv(Struct arg1) { 319 // TODO Auto-generated method stub 320 321 } 322 323 public void setLoginTimeout(Object arg1) { 324 // TODO Auto-generated method stub 325 326 } 327 328 public void setLogintimeout(int arg1) { 329 // TODO Auto-generated method stub 330 331 } 332 333 public void setMap(Map arg1) { 334 // TODO Auto-generated method stub 335 336 } 337 338 public void setMaxBlobSize(int arg1) { 339 // TODO Auto-generated method stub 340 341 } 342 343 public void setMaxClobSize(int arg1) { 344 // TODO Auto-generated method stub 345 346 } 347 348 public void setMaxConnections(int arg1) { 349 // TODO Auto-generated method stub 350 351 } 352 353 public void setMaxConnections(Object arg1) { 354 // TODO Auto-generated method stub 355 356 } 357 358 public void setMaxPooledStatements(int arg1) { 359 // TODO Auto-generated method stub 360 361 } 362 363 public void setPassword(String arg1) { 364 // TODO Auto-generated method stub 365 366 } 367 368 public void setPooling(boolean arg1) { 369 // TODO Auto-generated method stub 370 371 } 372 373 public void setPort(int arg1) { 374 // TODO Auto-generated method stub 375 376 } 377 378 public void setPort(Object arg1) { 379 // TODO Auto-generated method stub 380 381 } 382 383 public void setRemoveOnPageEnd(boolean arg1) { 384 // TODO Auto-generated method stub 385 386 } 387 388 public void setSelectMethod(String arg1) { 389 // TODO Auto-generated method stub 390 391 } 392 393 public void setSid(String arg1) { 394 // TODO Auto-generated method stub 395 396 } 397 398 public void setStrPrmUni(boolean arg1) { 399 // TODO Auto-generated method stub 400 401 } 402 403 public void setStrPrmUni(String arg1) { 404 // TODO Auto-generated method stub 405 406 } 407 408 public void setTimeout(int arg1) { 409 // TODO Auto-generated method stub 410 411 } 412 413 public void setType(String arg1) { 414 // TODO Auto-generated method stub 415 416 } 417 418 public void setType(int arg1) { 419 // TODO Auto-generated method stub 420 421 } 422 423 public void setUrl(String arg1) { 424 // TODO Auto-generated method stub 425 426 } 427 428 public void setUsername(String arg1) { 429 // TODO Auto-generated method stub 430 431 } 432 433 public void setVendor(String arg1) { 434 // TODO Auto-generated method stub 435 436 } 437 438}