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